您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Stop attention stealing
// ==UserScript== // @name Remove YouTube Popups // @namespace https://violentmonkey.github.io/ // @version 0.1 // @description Stop attention stealing // @author alopatindev // @license MIT // @match https://www.youtube.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @grant none // ==/UserScript== (function() { "use strict"; function randomPause() { const min = 3000; const max = 5000; return Math.floor(Math.random() * (max - min + 1)) + min; } const closeBanner = setInterval(function() { if (document.getElementsByClassName("yt-spec-button-shape-next").length > 0) { setTimeout(function() { const items = [...document.getElementsByClassName("yt-spec-button-shape-next")]; for (const i of items) { const label = i.getAttribute("aria-label"); if (label != null && label.includes("No thanks")) { i.click(); } } console.log("banner closed"); clearInterval(closeBanner); }, randomPause()); } else if ([...document.querySelectorAll("div")].filter((i) => i.textContent.trim() === "My Ad Center").length > 0) { setTimeout(function() { let items = document.querySelectorAll("button"); for (const i of items) { const label = i.getAttribute("aria-label"); if (label != null && label.includes("Close")) { console.log(i); i.click(); } } console.log("banner closed"); clearInterval(closeBanner); }, randomPause()); } else if (document.getElementsByClassName("ytd-single-option-survey-renderer").length > 0) { setTimeout(function() { const items = [...document.getElementsByClassName("ytd-single-option-survey-renderer")]; for (const i of items) { const label = i.getAttribute("icon"); if (label != null && label.includes("yt-icons:close")) { i.click(); } } console.log("banner closed"); clearInterval(closeBanner); }, randomPause()); } }, 300); })();