Greasy Fork 还支持 简体中文。

Twitch Turbo + Updated

Block all Twitch ads, auto-claim bonus points, auto-join raids, add clip download link, and promote Discord server

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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         Twitch Turbo + Updated
// @namespace    https://github.com/Brembo19
// @version      1.6.0
// @description  Block all Twitch ads, auto-claim bonus points, auto-join raids, add clip download link, and promote Discord server
// @author       Brembo19
// @match        *://*.twitch.tv/*
// @grant        none
// ==/UserScript==

(async () => {
    'use strict';

    const delay = ms => new Promise(resolve => setTimeout(resolve, ms));

    const blockAdsInVideo = () => {
        const videoElements = document.querySelectorAll('video');
        videoElements.forEach(video => {
            if (video.src.includes('ad_')) {
                video.src = '';
                console.info('Ad blocked in video stream');
            }
        });
    };

    const removeAdBanners = () => {
        const adSelectors = [
            '[aria-label="Advertisement"]',
            '.ad-banner',
            '.ad-slot',
            '.tw-ad-container',
            '[data-a-target="video-ad-banner"]',
            '[data-ad="true"]',
            'div[class*="ad-"]',
            'div[class*="sponsored"]',
            'iframe[src*="doubleclick"]'
        ];

        adSelectors.forEach(selector =>
            document.querySelectorAll(selector).forEach(ad => ad.remove())
        );
    };

    const observeDynamicContent = () => {
        const observer = new MutationObserver(() => removeAdBanners());
        observer.observe(document.body, { childList: true, subtree: true });
    };

    const autoClaimBonus = () => {
        const bonusObserver = new MutationObserver(() => {
            const bonus = document.querySelector('.community-points-summary .claimable-bonus__icon');
            if (bonus) {
                bonus.click();
                console.info('Bonus claimed');
            }
        });
        bonusObserver.observe(document.body, { childList: true, subtree: true });
    };

    const autoJoinRaid = () => {
        const raidObserver = new MutationObserver(() => {
            const raidButton = document.querySelector('button[data-test-selector="raid-banner__join-button"]');
            if (raidButton) {
                raidButton.click();
                console.info('Automatically joined the raid');
            }
        });
        raidObserver.observe(document.body, { childList: true, subtree: true });
    };

    const addClipDownloadLink = async () => {
        let attempts = 0;
        const tryAddingLink = async () => {
            const video = document.querySelector('.video-player__container video');
            if (video && video.src) {
                const downloadDiv = document.createElement('div');
                downloadDiv.innerHTML = `<a href="${video.src}" download>Download Clip</a>`;
                const fullButton = document.querySelector('[data-test-selector="clips-watch-full-button"]');
                if (fullButton && !document.querySelector('.clip-download-link')) {
                    downloadDiv.classList.add('clip-download-link');
                    fullButton.insertAdjacentElement("afterend", downloadDiv);
                    console.info('Clip download link added');
                }
            } else if (attempts < 5) {
                attempts++;
                await delay(1000);
                tryAddingLink();
            }
        };
        await tryAddingLink();
    };

    window.addEventListener('load', () => {
        blockAdsInVideo();
        removeAdBanners();
        observeDynamicContent();
        autoClaimBonus();
        autoJoinRaid();
        addClipDownloadLink();
    });

    setInterval(blockAdsInVideo, 1000);
    setInterval(removeAdBanners, 2000);

    console.info('Join our Discord: https://discord.gg/Cwm8fwknKC');

})();