banner
DarianBlog

DarianBlog

达里安博客-专注于技术分享与交流的博客。博客致力于创造一个简单而直接的技术学习平台。
email

Skip YouTube 5-second countdown ad script automatically.

First, go to the Google Chrome Web Store or another source to obtain the Tampermonkey extension and install it on your browser.

Screenshot_20231120092102
Then, click on "Add new script" to select it.

Screenshot_20231120092010
This will redirect you to the editor, where you should directly copy and paste the following code to replace the demo script code.

// ==UserScript==
// @name         Skip YouTube Ads Automatically
// @namespace    youtube
// @version      1.0
// @description  Automatically skip ads on YouTube webpages
// @author       Joey Gambler
// @match        *://www.youtube.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    function skipAd() {
        var skipButton = document.querySelector('.ytp-ad-text.ytp-ad-skip-button-text');
        if (skipButton) {
            skipButton.click();
            console.log("Click button");
        }
    }

    // Set detection interval
    var timer = setInterval(skipAd, 1000); // 1000 milliseconds = 1 second
})();

Screenshot_20231120092256
Click on "Editor", then "File", and finally "Save". After refreshing YouTube, you will notice that 5-second countdown ads will be automatically skipped. This method can avoid YouTube detection and replaces manual clicking to skip ads, without having to wait for 5 seconds. It may not work for other types of ads.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.