Forked from jeffmbellucci/disable_youtube_autoplay.js
Last active
July 12, 2022 15:39
-
-
Save bitelaserkhalif/68ad875768624f99e8d63efee690e65c 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 2.0 | |
// @description This script turns off Youtube's autoplay feature after the page loads. This is permanent, you hit the button, it'll forced to be off. | |
// @author Jeff Bellucci & bitelaserkhalif | |
// @match *://www.youtube.com/* | |
// @run-at document-idle | |
// @grant none | |
// @require https://code.jquery.com/jquery-3.6.0.min.js | |
// ==/UserScript== | |
/* globals $ */ | |
(function() { | |
'use strict'; | |
var intervalID = window.setInterval(disableAfterLoad, 500); | |
function disableAfterLoad() { | |
var autoplayToggle = $("#movie_player").find('.ytp-autonav-toggle-button').attr('aria-checked'); | |
if (autoplayToggle == 'true') { | |
$("#movie_player").find('.ytp-autonav-toggle-button').trigger( "click" ); | |
console.log('disabled: '+ autoplayToggle); | |
} else { | |
if (autoplayToggle == 'false') { | |
clearInterval(disableAfterLoad); | |
} | |
setTimeout(disableAfterLoad, 500); | |
} | |
} | |
disableAfterLoad(); | |
})(); |
Thank you so much. Finally I don't have to toggle autoplay off every time I open a new YouTube tab.
I dunno why YouTube breaks shit like this, autoplay for me stayed off for months if not years.
Thanks brother. It drove me crazy.
Welp, I guess youtube fixed that problem.
But this extension is useful for incognito/no sign in.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated with JQuery because youtube kept breaking stuff. (You refresh the page, autoplay goes back on even if you turn it off.)