Turn Off Youtube Annotations

Script to deactivate annotations toggle from youtube video settings

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 or Violentmonkey 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         Turn Off Youtube Annotations
// @version      1.0
// @description  Script to deactivate annotations toggle from youtube video settings
// @author       Hephaistoz
// @match        https://youtube.com/*
// @match        https://www.youtube.com/*
// @match        http://youtube.com/*
// @match        http://www.youtube.com/*
// @grant        none
// @namespace https://greasyfork.org/users/725305
// ==/UserScript==

(function () {
    'use strict';

    (function TurnOFF(){
        try {
            var ytplayer = document.getElementById("movie_player");

            if(ytplayer.getCurrentTime() <= 0.5)// check if has passed 0.5 seconds since video started // useful to not block the user from changing quality etc.
            {
                var settings_button = document.querySelector(".ytp-settings-button");
                settings_button.click(); settings_button.click(); // open and close settings, so annotations label is created

                var all_labels = document.getElementsByClassName("ytp-menuitem-label");
                for (var i = 0; i < all_labels.length; i++) {
                    if ((all_labels[i].innerHTML == "Annotations") || (all_labels[i].innerHTML == "Anotações") && (all_labels[i].parentNode.getAttribute("aria-checked") == "true")) { // find the correct label and see if it is active
                        all_labels[i].click(); // and in that case, click it
                    }
                }
            }
        } catch (e) {}
        setTimeout(TurnOFF,800);
    })();
})();