Last active
October 31, 2024 10:30
-
-
Save lassekongo83/bf57cd21b40846ff030eb10c26b45d6b to your computer and use it in GitHub Desktop.
Stops channels you're not subscribed to from autoplaying the channel trailer
This file contains hidden or 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 YouTube - Stop Channel Autoplay | |
// @namespace Violentmonkey Scripts | |
// @match https://www.youtube.com/* | |
// @grant none | |
// @version 1.0 | |
// @author https://github.com/lassekongo83 | |
// @description Stops channels you're not subscribed to from autoplaying the channel trailer | |
// ==/UserScript== | |
// https://stackoverflow.com/a/61511955 | |
function waitForElm(selector) { | |
return new Promise(resolve => { | |
if (document.querySelector(selector)) { | |
return resolve(document.querySelector(selector)); | |
} | |
const observer = new MutationObserver(mutations => { | |
if (document.querySelector(selector)) { | |
resolve(document.querySelector(selector)); | |
observer.disconnect(); | |
} | |
}); | |
observer.observe(document.body, { | |
childList: true, | |
subtree: true | |
}); | |
}); | |
} | |
function stopChannelAutoplay() { | |
waitForElm('[role="main"][page-subtype="channels"] ytd-channel-video-player-renderer video').then(function(elm) { | |
if (elm !== null) { | |
elm.addEventListener('loadstart', (e) => e.target.pause(), { passive: true }); | |
} | |
}); | |
} | |
stopChannelAutoplay(); |
Awesome, first script i found that actually works!
Does it still work? It keeps loading new videos automatically, even though button is there. I'm looking for that feature on subscriptions page and cant find a single thing that works :(
It works. Thank you.
Not Working anymore on chrome, installed it with tampermonkey
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome, first script i found that actually works!