Turn Off Youtube Annotations

Script to deactivate annotations toggle from youtube video settings

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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);
    })();
})();