您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Bypass YouTube ads with some player tricks.
// ==UserScript== // @name YouTube AdBlocker // @namespace http://tampermonkey.net/ // @version 0.1 // @description Bypass YouTube ads with some player tricks. // @author You // @match https://www.youtube.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @grant none // ==/UserScript== (function() { const wait = ms => new Promise((resolve) => setTimeout(resolve, ms)); const clickSkipButton = () => { document.querySelector(".ytp-ad-skip-button")?.click(); document.querySelector(".ytp-ad-skip-button-modern")?.click(); }; const skipAdIfExists = async () => { const videoContainer = document?.getElementById("movie_player"); if (!videoContainer) return; const isAd = videoContainer?.classList.contains("ad-interrupting") || videoContainer?.classList.contains("ad-showing"); if (!isAd) return; const videoPlayer = document.getElementsByClassName("video-stream")[0]; if (videoPlayer) { videoPlayer.muted = true; videoPlayer.currentTime = videoPlayer.duration - 0.1; if (videoPlayer.paused) { videoPlayer.play(); } await wait(200); } clickSkipButton(); await wait(100); return skipAdIfExists(); }; skipAdIfExists(); })();