Last active
July 16, 2024 17:15
-
-
Save jeffmbellucci/8db3a8b27664dac6b8f9cf10b416b433 to your computer and use it in GitHub Desktop.
Turn off/disable YouTube autoplay feature
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
// To run, install GreaseMonkey or TamperMonkey extension in your browser | |
// Copy this code into new user script, and enable | |
// ==UserScript== | |
// @name Disable Youtube autoplay | |
// @version 1.0 | |
// @description This script turns off Youtube's newest autoplay feature after the page loads | |
// @author Jeff Bellucci | |
// @match *://www.youtube.com/* | |
// @run-at document-start | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function uncheck(toggle) { | |
if (toggle.hasAttribute('checked')) { | |
toggle.click(); | |
} | |
} | |
function disableAfterLoad() { | |
var autoplayToggle = document.getElementById('toggle'); | |
if (autoplayToggle) { | |
uncheck(autoplayToggle); | |
} else { | |
setTimeout(disableAfterLoad, 500); | |
} | |
} | |
disableAfterLoad(); | |
})(); |
I have forked and modded this userscript due to youtube breaking stuff (You refresh the page, autoplay goes back on even if you turn it off). The autoplay got moved into html5 player, and the only way I can do it is with JQuery. My version would not allow autoplay to be turned on, it'll turn off again because of youtube bug above.
So, is there still a workable JS script as of the present?
@scrutinizer11 this one works for me https://gist.githubusercontent.com/sidneys/02a9025ae1f23aefe1f4ea02e78b0ac8/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@JohnyP36 You need to use a script running extension. Personally, I prefer Tampermonkey, but there are a number of options out there that let you save different scripts and run them as you see fit, on a single website, on all websites, on document ready, etc, etc. They are quite powerful.