From 0ee3d4f4cd9674fbd9398615d8054de0ebd9c130 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Sun, 17 Nov 2024 20:53:58 -0600 Subject: replace spaces with tabs --- youtube/piped-button.js | 86 ++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 51 deletions(-) (limited to 'youtube/piped-button.js') diff --git a/youtube/piped-button.js b/youtube/piped-button.js index fd4b331..60cd7f2 100644 --- a/youtube/piped-button.js +++ b/youtube/piped-button.js @@ -18,62 +18,46 @@ const instanceUrl = `${instanceProtocol}//${instanceHostname}` const redirectButtonId = "piped-button" GM_addStyle(` - a#${redirectButtonId} button { - background-color: #272727; - border-radius: 18px; - border: none; - color: white; - cursor: pointer; - display: flex; - font-family: "Roboto","Arial",sans-serif; - font-weight: 500; - height: 36px; - padding: .25em 1em .25em .65em; - text-decoration: none; - } - a#${redirectButtonId} button:hover { background-color: #3f3f3f; } - a#${redirectButtonId} button * { align-self: center; max-height: 100%; } + a#${redirectButtonId} button { + background-color: #272727; + border-radius: 18px; + border: none; + color: white; + cursor: pointer; + display: flex; + font-family: "Roboto","Arial",sans-serif; + font-weight: 500; + height: 36px; + padding: .25em 1em .25em .65em; + text-decoration: none; + } + a#${redirectButtonId} button:hover { background-color: #3f3f3f; } + a#${redirectButtonId} button * { align-self: center; max-height: 100%; } `) function newUrl() { - return `${instanceProtocol}//${instanceHostname}${document.location.pathname}${document.location.search}` + return `${instanceProtocol}//${instanceHostname}${document.location.pathname}${document.location.search}` } if (!document.getElementById(redirectButtonId)) { - const redirectButton = document.createElement("a") - const redirectButtonC = redirectButton.appendChild(document.createElement("button")) - const redirectButtonImg = redirectButtonC.appendChild(document.createElement("img")) - const redirectButtonTxt = redirectButtonC.appendChild(document.createElement("span")) - redirectButton.id = redirectButtonId - redirectButtonImg.src = instanceUrl + instanceIconLogo - redirectButtonImg.alt = "(Down)" // Logo effectively acts as a test to see whether the instance is up or not as a bonus - redirectButtonTxt.innerText = "Piped" - - redirectButton.addEventListener("mouseover", () => { redirectButton.href = newUrl() }) - - /* Insert */ - document.body.addEventListener("yt-navigate-finish", () => { - - setTimeout(() => { - const headContainer = document.querySelector("#masthead-container #container #start") - headContainer.appendChild(redirectButton) - /* - const actionDiv = document.querySelector("#actions #menu") - - const pipedLink = actionDiv.appendChild(document.createElement("a")) - pipedLink.id = "piped" - pipedLink.href = `${document.location.protocol}//${pipedInstance}${document.location.pathname}${document.location.search}` - - const pipedButton = pipedLink.appendChild(document.createElement("button")) // Simplify styling - - const pipedLogo = pipedButton.appendChild(document.createElement("img")) - pipedLogo.src = `${document.location.protocol}//${pipedInstance}/img/icons/logo.svg` - pipedLogo.alt = "(Down)" // Indicates instance is down if logo cannot be loaded - - const pipedText = pipedButton.appendChild(document.createElement("span")) - pipedText.innerText = "Piped" - */ - }, 500) // Wait 500ms for page load to finish after event called - }) + const redirectButton = document.createElement("a") + const redirectButtonC = redirectButton.appendChild(document.createElement("button")) + const redirectButtonImg = redirectButtonC.appendChild(document.createElement("img")) + const redirectButtonTxt = redirectButtonC.appendChild(document.createElement("span")) + redirectButton.id = redirectButtonId + redirectButtonImg.src = instanceUrl + instanceIconLogo + redirectButtonImg.alt = "(Down)" // Logo effectively acts as a test to see whether the instance is up or not as a bonus + redirectButtonTxt.innerText = "Piped" + + redirectButton.addEventListener("mouseover", () => { redirectButton.href = newUrl() }) + + /* Insert */ + document.body.addEventListener("yt-navigate-finish", () => { + + setTimeout(() => { + const headContainer = document.querySelector("#masthead-container #container #start") + headContainer.appendChild(redirectButton) + }, 500) // Wait 500ms for page load to finish after event called + }) } -- cgit v1.2.3