Greasy Fork

Greasy Fork is available in English.

Twitch Turbo +

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

当前为 2024-10-09 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Twitch Turbo +
// @namespace    https://github.com/Brembo19
// @version      1.5.0
// @description  Block all Twitch ads, automatically 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 video = document.querySelector('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-ad="true"]',
            'div[class*="ad-"]',
            'div[class*="sponsored"]'
        ];

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

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

    const autoClaimBonus = () => {
        let claiming = false;

        new MutationObserver(() => {
            const bonus = document.querySelector('.claimable-bonus__icon');
            if (bonus && !claiming) {
                bonus.click();
                claiming = true;
                console.info('Bonus claimed');
                delay(Math.random() * 1000 + 1000).then(() => claiming = false);
            }
        }).observe(document.body, { childList: true, subtree: true });
    };

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

    const geturl = () => {
        console.log('[CDL] searching');
        const link = document.querySelector(".video-ref > video")?.getAttribute("src");
        if (!link) {
            console.log('[CDL] waiting');
            if (fail < 5) {
                fail++;
                setTimeout(geturl, 500);
            }
        } else {
            console.log('[CDL] found link: ' + link);
            const div = document.createElement('div');
            div.innerHTML = `<a href="${link}">Download</a>`;
            const button = document.querySelector('[data-test-selector="clips-watch-full-button"]');
            button?.insertAdjacentElement("afterend", div);
        }
    };

    window.addEventListener('load', () => {
        geturl();
    });

    blockAdsInVideo();
    removeAdBanners();
    observeDynamicContent();
    autoClaimBonus();
    autoJoinRaid();

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

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

})();