Block Twitch Prime Popup

Block a specific iframe from loading on Twitch.tv

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Block Twitch Prime Popup
// @namespace    https://greasyfork.org/en/users/1200587-trilla-g
// @version      1.0
// @description  Block a specific iframe from loading on Twitch.tv
// @author       Trilla_G
// @match        *://*.twitch.tv/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to remove the iframe with the specified src
    function removeIframe() {
        const iframes = document.querySelectorAll('iframe[src*="supervisor.ext-twitch.tv/supervisor/v1/index.html"]');
        iframes.forEach(iframe => {
            iframe.parentNode.removeChild(iframe);
            console.log('Blocked iframe: supervisor.ext-twitch.tv/supervisor/v1/index.html');
        });
    }

    // Run the function immediately in case the iframe is already in the DOM
    removeIframe();

    // Use a MutationObserver to detect and remove the iframe if it gets added dynamically
    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            mutation.addedNodes.forEach(node => {
                if (node.tagName === 'IFRAME' && node.src.includes('supervisor.ext-twitch.tv/supervisor/v1/index.html')) {
                    node.parentNode.removeChild(node);
                    console.log('Blocked dynamically added iframe: supervisor.ext-twitch.tv/supervisor/v1/index.html');
                }
            });
        });
    });

    // Start observing the document for added nodes
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();