Skip to content

Instantly share code, notes, and snippets.

@Sytric
Last active January 20, 2018 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Sytric/4700ee977f427e22c9b0 to your computer and use it in GitHub Desktop.
Save Sytric/4700ee977f427e22c9b0 to your computer and use it in GitHub Desktop.
Force turns off autoplay and annotations on all youtube pages (Waits 10sec for page load)
// ==UserScript==
// @name KillAutoplay
// @namespace http://www.sysadminarena.com/ntsk
// @description Turns off annoying Youtube features
// @include /^https?://www\.youtube\.com/.*$/
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @run-at document-end
// @version 2.0.1
// @grant none
// ==/UserScript==
// NOTE: The normal $(document).ready(function{...}); syntax for whatever reason doesn't work, worth looking into by someone. Shitty timer is shitty.
setTimeout(
function(){
//activate the settings menu - without this we can't click anything else
document.querySelectorAll(".ytp-settings-button").item(0).click();
//autoplay
if(document.querySelectorAll("div[role='menuitemcheckbox']")[0].getAttribute("aria-checked") == "true")
document.querySelectorAll("div[role='menuitemcheckbox']")[0].click();
//annotations
if(document.querySelectorAll("div[role='menuitemcheckbox']")[1].getAttribute("aria-checked") == "true")
document.querySelectorAll("div[role='menuitemcheckbox']")[1].click();
}
, 10000);
//Alternative Method - I've found gets overridden by the actual player, thus the timeout to wait around for the doc to load.
// if(document.getElementById("autoplay-checkbox").checked) $( "#autoplay-checkbox" ).trigger( "click" );
@thienha1
Copy link

Can you make scripts that set a timer to automatically pause/stop on all Youtube embed videos? Like pause a video after X seconds!!?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment