andwan0 / YouTube Auto-DisLike Playlist

// ==UserScript==
// @name           YouTube Auto-DisLike Playlist
// @namespace      http://userscripts.org/users/23652
// @description    Automatically clicks the 'DisLike' and then 'Next' button in a playlist
// @include        http://*.youtube.com/watch*v=*
// @include        http://youtube.com/watch*v=*
// @include        https://*.youtube.com/watch*v=*
// @include        https://youtube.com/watch*v=*
// @copyright      andwan0
// @version        2
// @license        GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
// @require        https://greasyfork.org/scripts/1884-gm-config/code/GM_config.js?version=4836
// @require        https://greasyfork.org/scripts/1885-joesimmons-library/code/JoeSimmons'%20Library.js?version=7915
// @require        https://greasyfork.org/scripts/2104-youtube-button-container-require/code/YouTube%20-%20Button%20Container%20(@require).js?version=5493
// @grant          GM_getValue
// @grant          GM_setValue
// @grant          GM_registerMenuCommand
// ==/UserScript==

/* CHANGELOG

*/



(function () {
    'use strict';

    var intv, timeStart;

    // Run a function when the page is fully loaded
    JSL.runAt('end', function() {

        // try to 'like' the video for 30 seconds max
        window.setTimeout(function () {
            timeStart = Date.now();

            intv = JSL.setInterval(function () {
                reset();
            }, 750);
        }, 61000);

	window.setTimeout(doDislike, 1000);
	window.setTimeout(doNext, 59000);

    });

    //keep it simple with basic functions...
    function reset() {
        if ( (Date.now() - timeStart) > 5000) {
            location.reload(true);
        }
    }

    function doLike() {
        if (document.getElementsByClassName("ytd-subscribe-button-renderer")[0].attributes["subscribed"] !== undefined
            && document.getElementsByClassName('ytd-toggle-button-renderer')[1].classList.value.search("active") == -1) {
            document.getElementsByClassName('ytd-toggle-button-renderer')[1].click();
        }
    }

    function doDislike() {

        if (document.getElementsByClassName("ytd-subscribe-button-renderer")[0].attributes["subscribed"] !== undefined
            && document.getElementsByClassName('ytd-toggle-button-renderer')[4].classList.value.search("active") == -1) {
            document.getElementsByClassName('ytd-toggle-button-renderer')[4].click();
        }
    }

    function doNext() {
        var nextButton = document.querySelector('.ytp-next-button');
        nextButton.click();
    }

}());