Disable Youtube autoplay

This script turns off Youtube's newest autoplay feature after the page loads

As of 09/07/2018. See the latest version.

// 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      1.2
// @description  This script turns off Youtube's newest autoplay feature after the page loads
// @author       Jeff Bellucci
// @match        *://www.youtube.com/*
// @run-at       document-start
// @grant        none
// @namespace http://tampermonkey.net/
// ==/UserScript==

(function() {
    'use strict';
    function uncheck(toggle) {
        if (toggle.hasAttribute("checked")) {
            toggle.click();
        }
    }

    function disableAfterLoad() {
        var autoplayToggle = document.getElementById('improved-toggle');
        if (autoplayToggle) {
            uncheck(autoplayToggle);
        } else {
            setTimeout(disableAfterLoad, 500);
        }
    }

    disableAfterLoad();
})();