diff options
| author | Tim Keller <tjk@tjkeller.xyz> | 2026-09-21 23:18:15 -0500 |
|---|---|---|
| committer | Tim Keller <tjk@tjkeller.xyz> | 2026-09-21 23:18:15 -0500 |
| commit | b88ff9fe8e80cc4d8aa0db2a3595ab10f40f4439 (patch) | |
| tree | 234e442aaaff83d1a50fb15998690dc4f0bfe6c6 /scripts/youtube-embedtube-button.user.js | |
| parent | 531a76993e2babcecc69be7b5333729078c8dd9b (diff) | |
| download | userscripts-b88ff9fe8e80cc4d8aa0db2a3595ab10f40f4439.tar.xz userscripts-b88ff9fe8e80cc4d8aa0db2a3595ab10f40f4439.zip | |
move all scripts to scripts dir
Diffstat (limited to 'scripts/youtube-embedtube-button.user.js')
| -rw-r--r-- | scripts/youtube-embedtube-button.user.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/scripts/youtube-embedtube-button.user.js b/scripts/youtube-embedtube-button.user.js new file mode 100644 index 0000000..f168eb9 --- /dev/null +++ b/scripts/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/scripts/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 + }) +} |
