Created
July 24, 2023 02:13
-
-
Save Element118/41693ef27e066f5b9c600b91a757513d to your computer and use it in GitHub Desktop.
Add Button to Youtube Shorts - Change to Video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Change to Video | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.youtube.com/shorts/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Create a new stylesheet for the elements you want to create | |
// Hope for the best that the elements you want to make are not made already | |
var styleEl = document.createElement('style'); | |
document.getElementsByTagName("head")[0].appendChild(styleEl); | |
var styleSheet = styleEl.sheet; | |
// Stylesheet rules | |
styleSheet.insertRule(".multiplier-box { background-color: rgb(255, 255, 255); position: absolute; left: 100px; z-index: 1000; }", 0); | |
styleSheet.insertRule(".multiplier-button { background-color: rgb(191, 191, 191); padding-left: 10px; }", 1); | |
var tryToAdd = setInterval(function() { | |
var actionBoxes = document.getElementsByTagName("ytd-reel-player-overlay-renderer"); | |
for (var i=0;i<actionBoxes.length;i++) { | |
let children = actionBoxes[i].children; | |
let addTo = null; | |
let addButton = true; | |
for (let j=0;j<children.length;j++) { | |
if (children[j].id === "actions") { | |
let actionChildren = (addTo = children[j]).children; | |
for (let k=0;k<actionChildren.length;k++) { | |
if (actionChildren[k].className === "multiplier-button") { | |
addButton = false; | |
} | |
} | |
break; | |
} | |
} | |
if (!addButton) { continue; } | |
var newButton = document.createElement("button"); | |
newButton.textContent = "Make Video"; | |
newButton.classList.add("multiplier-button"); | |
newButton.addEventListener("click", function() { | |
console.log(window.location.href.replace("shorts/", "video?v=")); | |
window.location.href = window.location.href.replace("shorts/", "watch?v="); | |
}); | |
addTo.appendChild(newButton); | |
} | |
}, 500); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment