Last active
December 15, 2021 06:34
-
-
Save heavyLobster2/4f20db397e4ca84161e7 to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name Remove YouTube Autoplay | |
// @description Disables the Autoplay feature on YouTube videos | |
// @version 1.1.6 | |
// @author heavyLobster2 | |
// @namespace github.com/heavyLobster2 | |
// @downloadURL https://gist.github.com/heavyLobster2/4f20db397e4ca84161e7/raw/RemoveYouTubeAutoplay.user.js | |
// @match *://www.youtube.com/* | |
// @grant none | |
// @noframes | |
// ==/UserScript== | |
(function () { | |
"use strict"; | |
function removeAutoplay() { | |
var autoplay; | |
autoplay = document.querySelector(".autoplay-bar"); | |
if (autoplay) { | |
var toggle = document.querySelector(".autoplay-bar #autoplay-checkbox"); | |
if (toggle && toggle.checked) toggle.click(); | |
autoplay.remove(); | |
var sidebarSeparator = document.querySelector("hr.watch-sidebar-separation-line"); | |
if (sidebarSeparator) sidebarSeparator.remove(); | |
} | |
autoplay = document.querySelector("ytd-compact-autoplay-renderer"); | |
if (autoplay) { | |
var toggle = document.querySelector("ytd-compact-autoplay-renderer #toggle"); | |
if (toggle) { | |
if (toggle.wrappedJSObject) toggle = toggle.wrappedJSObject; | |
if (toggle.checked) toggle.click(); | |
} | |
autoplay.remove(); | |
} | |
autoplay = document.querySelector("div.ytp-autonav-toggle-button"); | |
if (autoplay) { | |
if (autoplay.wrappedJSObject) autoplay = autoplay.wrappedJSObject; | |
if (autoplay.getAttribute("aria-checked") === "true") autoplay.click(); | |
} | |
var annoying = document.querySelector("ytd-mealbar-promo-renderer"); | |
if (annoying) { annoying.remove(); } | |
} | |
var observer = new MutationObserver(function (mutations) { | |
removeAutoplay(); | |
}); | |
observer.observe(document, { subtree: true, childList: true}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you make scripts that set a timer to automatically pause/stop on all Youtube embed videos? Like pause a video after X seconds!!?