YouTubeCleaner

try to save the world and remove google's privacy reminder

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         YouTubeCleaner
// @namespace    org.free.world
// @version      0.1.1
// @description  try to save the world and remove google's privacy reminder
// @author       You
// @include      /^https://w*\.?youtube\..*/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    window.onload = function () {

        console.log("YouTubeCleaner");

        var targetNode = document.getElementsByTagName("body")[0];
        var targetNode2 = document.getElementsByTagName("html")[0];
        var config = { attributes: true, childList: true, subtree: true };

        var callback = function(mutationsList, observer) {
            for(var mutation of mutationsList) {
                if (mutation.type == 'childList') {
                    removeCrap();
                }
            }
        };

        var observer = new MutationObserver(callback);
        observer.observe(targetNode, config);

    }
    function removeCrap()
    {
        var foundNode = contains('yt-formatted-string', 'REMIND ME LATER');
        if(foundNode.length > 0)
        {
            foundNode[0].parentNode.parentNode.parentNode.click();
        }

        var foundNodeDE = contains('yt-formatted-string', 'SPÄTER');
        if(foundNodeDE.length > 0)
        {
            foundNodeDE[0].parentNode.parentNode.parentNode.click();
        }
    }
    function contains(selector, text) {
        var elements = document.querySelectorAll(selector);
        return Array.prototype.filter.call(elements, function(element){
            return RegExp(text).test(element.innerText);
        });
    }
})();