🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

BypassYoutubePub

Bypass YouTube publicity (French Version) and handle multiple languages

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

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.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==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
})();