Skip to content

Instantly share code, notes, and snippets.

@codeasashu
Forked from Sytric/KillAutoplay.user.js
Created October 3, 2015 13:59
Show Gist options
  • Save codeasashu/005d046b355727bc8b01 to your computer and use it in GitHub Desktop.
Save codeasashu/005d046b355727bc8b01 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" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment