Skip to content

Instantly share code, notes, and snippets.

@Ravlissimo
Forked from SoullessJoe/#YouTube Extensions
Last active October 5, 2025 17:25
Show Gist options
  • Save Ravlissimo/b92983d370706b8a4f7ba7ff390a1e38 to your computer and use it in GitHub Desktop.
Save Ravlissimo/b92983d370706b8a4f7ba7ff390a1e38 to your computer and use it in GitHub Desktop.
YouTube
My youtube scripts/extensions
const delay = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms));
}
// Variable ytInitialData.metadata seems to be populated on first page load, subsequent navigations are null, so I'm only inserting the button on first page load and removing it on navigation
// TODO: find a way to let the button work on navigation (very low priority)
async function insertChannelAllVideosButton() {
const firstUrl = location.href;
let insertButton = true;
const observer = new MutationObserver(function(mutations) {
if (location.href !== firstUrl) {
insertButton = false;
let allButton = document.querySelector("#channel-container #allvideos-button");
if (allButton) {
allButton.remove();
}
observer.disconnect();
}
});
const config = {subtree: true, childList: true};
observer.observe(document, config);
while (insertButton) {
if (!document.querySelector("#channel-container #allvideos-button")) {
let buttons = document.querySelector("#channel-container #buttons");
if (buttons) {
let html = '<div class="channel-action style-scope ytd-c4-tabbed-header-renderer" id="allvideos-button"><button class="yt-spec-button-shape-next yt-spec-button-shape-next--outline yt-spec-button-shape-next--mono yt-spec-button-shape-next--size-m" onclick="(() => window.location=' + "'" + 'https://www.youtube.com/playlist?list=UU' + "' + " + 'ytInitialData.metadata.channelMetadataRenderer.externalId.substring(2))()"><span class="yt-core-attributed-string yt-core-attributed-string--white-space-no-wrap" role="text">All Videos</span></button></div>';
let frag = document.createRange().createContextualFragment(html);
buttons.appendChild(frag);
}
}
await delay(500);
}
}
insertChannelAllVideosButton();
// Simple script that replaces youtube playback error with embedded video
const delay = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function start() {
while (true) {
if (!document.querySelector("#replace-success")) {
await replacePlaybackError();
}
else {
await updateSrc();
}
await delay(1000);
}
}
async function replacePlaybackError() {
const iframePartOne = "<iframe id='replace-success' width='100%' height='100%' src='https://www.youtube.com/embed/";
const iframePartTwo = "' title='YouTube video player' frameborder='0' allow='accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share' allowfullscreen></iframe>";
while (!document.querySelector("yt-playability-error-supported-renderers")) {
await delay(500);
}
let id = (new URL(document.location)).searchParams.get("v");
let iframe = iframePartOne + id + iframePartTwo;
document.querySelector("yt-playability-error-supported-renderers").innerHTML = iframe;
}
async function updateSrc() {
let id = (new URL(document.location)).searchParams.get("v");
let src = 'https://www.youtube.com/embed/' + id;
let iframe = document.querySelector("#replace-success");
if (src === iframe.src) {
await delay(5000);
}
else {
iframe.src = src;
}
}
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment