Youtube Ad Auto Skipper

Automatically click Ad Skip button on Youtube

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Youtube Ad Auto Skipper
// @name:ja      Youtube広告自動スキップ
// @namespace    https://greasyfork.org/users/175598
// @version      3.01
// @description  Automatically click Ad Skip button on Youtube
// @description:ja  自動でYoutubeの広告のスキップボタンを押します
// @author       N.Y.Boyu
// @match        https://www.youtube.com/*
// @exclude      https://www.youtube.com/live_chat?*
// @exclude      https://www.youtube.com/live_chat_replay?*
// @grant        none
// @license      MIT
// ==/UserScript==
(function(){
    var MutationObserver=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;
    if(!MutationObserver){
        return console.error("YAS: Sorry, but this browser is NOT compatible with Youtube Ad Auto Skipper.");
    }
    try{if((window.self!==window.top)&&(document.URL.substring(23,30)!=="/embed/")){
        return console.log("YAS: This frame will not contain video...");
    }}catch(e){}
    console.log("YAS: Youtube Ad Auto Skipper is enabled.");

    var container;
    var check=function(){
        var button=container.getElementsByClassName("ytp-ad-skip-button")[0]||
                   container.getElementsByClassName("ytp-ad-skip-button-modern")[0]||
                   container.getElementsByClassName("ytp-skip-ad-button")[0];
        if(button){
            button.click();
            console.log("YAS: Skipped at "+new Date());
        }
    };
    var initObserver;
    var init=function(){
        if(container=document.getElementById("movie_player")){
            console.log("YAS: Video container detected.");
            initObserver.disconnect();
            new MutationObserver(check).observe(container,{childList:true,subtree:true});
            check();
        }
    };
    (initObserver=new MutationObserver(init)).observe(document.body,{childList:true,subtree:true});
    init();
})();