Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bitelaserkhalif/68ad875768624f99e8d63efee690e65c to your computer and use it in GitHub Desktop.
Save bitelaserkhalif/68ad875768624f99e8d63efee690e65c to your computer and use it in GitHub Desktop.
Turn off/disable YouTube autoplay feature
// 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();
})();
@BlauesPink
Copy link

Thanks brother. It drove me crazy.

@bitelaserkhalif
Copy link
Author

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