YouTube Fuck Autoplay

Hey YouTube, I'm the one to say what I watch. Fuck you.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name     YouTube Fuck Autoplay
// @description Hey YouTube, I'm the one to say what I watch. Fuck you.
// @include  https://www.youtube.com/*
// @version  2
// @grant    none
// @noframes
// @namespace https://greasyfork.org/en/users/175405-anao9aaw/wtf2
// @license MIT
// ==/UserScript==

function turnOffAutoplay() {
    var l = document.getElementsByClassName("ytp-button");
    var l2 = Array.from(l).filter(e => {return e.dataset.tooltipTargetId == "ytp-autonav-toggle-button";});
    console.log(`Seeing ${l2.length} elements: ${l2}`);
    var e = l2[0];
    console.log(e.title);
    if (e.title.endsWith("on")) {
        e.click();
        console.log(e.title);
    }
}
setInterval(turnOffAutoplay, 30 * 1000); // 30 seconds
// Can't use setTimeout because apparently the UI doesn't work while the tab isn't active. Ugh!