From 0af9cdb8b7b415650a3535cdf4338907a09dca09 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Mon, 21 Sep 2026 22:21:59 -0500 Subject: mv piped button to embedtube button --- youtube/embedtube-button.user.js | 65 ++++++++++++++++++++++++++++++++++++++++ youtube/piped-button.user.js | 63 -------------------------------------- 2 files changed, 65 insertions(+), 63 deletions(-) create mode 100644 youtube/embedtube-button.user.js delete mode 100644 youtube/piped-button.user.js diff --git a/youtube/embedtube-button.user.js b/youtube/embedtube-button.user.js new file mode 100644 index 0000000..6f50e31 --- /dev/null +++ b/youtube/embedtube-button.user.js @@ -0,0 +1,65 @@ +// ==UserScript== +// @name Redirect to EmbedTube +// @namespace Violentmonkey Scripts +// @match https://www.youtube.com/* +// @grant GM_addStyle +// @homepageURL https://git.tjkeller.xyz/userscripts/about +// @downloadURL https://git.tjkeller.xyz/userscripts/plain/youtube/embedtube-button.user.js +// @version 1.1 +// @author tjkeller.xyz +// @description 3/9/2024, 8:38:47 PM +// ==/UserScript== + +/* Config */ +const instanceHostname = "yt.tjkeller.xyz" +const instanceProtocol = "https:" +const instanceIconLogo = "/static/favicon.svg" + +const instanceUrl = `${instanceProtocol}//${instanceHostname}` + +const redirectButtonId = "embedtube-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%; } +`) + + +function newUrl() { + 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 = "EmbedTube" + + 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 + }) +} diff --git a/youtube/piped-button.user.js b/youtube/piped-button.user.js deleted file mode 100644 index 60cd7f2..0000000 --- a/youtube/piped-button.user.js +++ /dev/null @@ -1,63 +0,0 @@ -// ==UserScript== -// @name Piped Button youtube.com -// @namespace Violentmonkey Scripts -// @match https://www.youtube.com/* -// @grant GM_addStyle -// @version 1.0 -// @author - -// @description 3/9/2024, 8:38:47 PM -// ==/UserScript== - -/* Config */ -const instanceHostname = "piped.tjkeller.xyz" -const instanceProtocol = "https:" -const instanceIconLogo = "/img/icons/logo.svg" - -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%; } -`) - - -function newUrl() { - 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) - }, 500) // Wait 500ms for page load to finish after event called - }) -} -- cgit v1.3.1