// ==UserScript==
// @name YT - Autoplay Disable
// @namespace abbc87ec891f11df2269f2af61132b1d6700942c
// @version 0.2
// @description Disables the autoplay toggle on YouTube
// @author /u/AyrA_ch
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
// Changelog
// 0.2 Changed title to match other scripts
// 0.1 Initial version
(function ($) {
'use strict';
var scanned = false;
var check = function () {
if (scanned) {
//Remove Checker
check = function () {};
return;
}
//Old Design
var btnOld = $("#autoplay-checkbox");
if (btnOld) {
if (btnOld.checked) {
btnOld.click();
console.log("Autoplay disabled");
}
} else {
//New Design
var btnNew = $("#toggle");
if (btnNew) {
if (btnNew.getAttribute("aria-pressed") == "true") {
btnNew = $("#toggleButton");
if (btnNew) {
btnNew.click();
console.log("Autoplay disabled");
}
}
}
}
};
var observer = new MutationObserver(check);
var config = {
attributes: true,
childList: true,
characterData: false
};
observer.observe(document.body, config);
})(document.querySelector.bind(document));
/*
LICENSE:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
The full license text can be found here: http://creativecommons.org/licenses/by-nc-sa/4.0/
The link has an easy to understand version of the license and the full license text.
DISCLAIMER:
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/