BypassYoutubePub

Bypass YouTube publicity (French Version) and handle multiple languages

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         BypassYoutubePub
// @namespace    http://tampermonkey.net/
// @version      2.3
// @description  Bypass YouTube publicity (French Version) and handle multiple languages
// @author       MeGaBOuSsOl
// @match        https://www.youtube.com/*
// @icon         https://www.google.com/s2/favicons?domain=youtube.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Liste des textes de boutons "Skip" ou "Ignorer" dans différentes langues
    const skipButtonTexts = [
        "Ignorer l'annonce", // Français
        "Skip Ad",           // Anglais
        "Anzeige überspringen", // Allemand
        "Saltar anuncio",    // Espagnol
        "Salta annuncio",    // Italien
        "広告をスキップ",     // Japonais
        "跳过广告",           // Chinois
        "광고 건너뛰기",      // Coréen
        "Пропустить рекламу" // Russe
    ];

    // Fonction pour détecter et cliquer sur le bouton "Skip" ou "Ignorer"
    function skipAd() {
        // Rechercher tous les boutons possibles
        const buttons = document.querySelectorAll('.ytp-ad-skip-button, .ytp-ad-skip-button-icon, .ytp-skip-ad-button');

        buttons.forEach(button => {
            if (skipButtonTexts.some(text => button.textContent.includes(text))) {
                button.click();
                console.log('Publicité skippée !');
                clearInterval(checkInterval); // Arrêter l'intervalle une fois l'action effectuée
            }
        });
    }

    // Fonction pour fermer les bannières publicitaires
    function closeBannerAds() {
        const closeButtons = document.querySelectorAll('.ytp-ad-overlay-close-button, .ytp-ad-preview-text, .ytp-ad-skip-button');

        closeButtons.forEach(button => {
            button.click();
            console.log('Bannière publicitaire fermée !');
        });
    }

    // Vérifier toutes les secondes
    const checkInterval = setInterval(() => {
        skipAd();
        closeBannerAds();
    }, 1000);

    // Arrêter l'intervalle après 5 minutes pour éviter une utilisation excessive du CPU
    setTimeout(() => {
        clearInterval(checkInterval);
        console.log('Arrêt du script après 5 minutes.');
    }, 300000); // 5 minutes
})();