4

Make your own YouTube AdBlocker for FREE!

 3 years ago
source link: https://dev.to/cristoferk/make-your-own-youtube-adblocker-for-free-2dpe
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Cover image for Make your own YouTube AdBlocker for FREE!

Make your own YouTube AdBlocker for FREE!

Apr 10

・1 min read

Hello! Are you tired of watching youtube ads? Why not make your own adblocker for free!
Let's start!

setInterval(function(){

    var skipButton = document.getElementsByClassName("ytp-ad-skip-button");
    if(skipButton != undefined && skipButton.length > 0) {
            console.log("Ad detected");
            skipButton[0].click();
    }

}, 3000)
Enter fullscreen modeExit fullscreen mode
{

    "manifest_version": 2,
    "name": "Youtube Ad Skiper",
    "description": "This extension will help you to watch your favorite videos, without the intervention of Advertisements!",
    "version": "1.0",
    "author": "CristoferK",
    "icons":{
        "600":"logo.png"
    },

    "browser_action":{
        "default_popup":"popup.html"
    },

    "content_scripts": [{
        "js": ["script.js"],
        "run_at": "document_idle",
        "matches": ["<all_urls>"]
    }],
    "permissions": [
        "tabs",
        "activeTab"
    ]

}
Enter fullscreen modeExit fullscreen mode

Don't forget to subscribe to my YouTube channel for programming tutorials: https://www.youtube.com/channel/UCFzeA3xC-_i4ZT-XwcwsJxQ


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK