Turn Off Youtube Annotations

Script to deactivate annotations toggle from youtube video settings

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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