DEV Community

loading...
Cover image for Make your own YouTube AdBlocker for FREE!

Make your own YouTube AdBlocker for FREE!

cristoferk profile image CristoferK ・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 mode Exit 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 mode Exit fullscreen mode

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

Discussion (3)

pic
Editor guide
Collapse
thebugcoder profile image
TheBugCoder

Nice!!

Collapse
cristoferk profile image
CristoferK Author

Don't forget to subscribe to my YouTube channel for programming tutorials: youtube.com/channel/UCFzeA3xC-_i4Z...

Some comments have been hidden by the post's author - find out more