Twitch Front Page Carousel Remover

Removes front page carousel and mutes its audio

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Twitch Front Page Carousel Remover
// @version      1.1
// @icon         https://img.icons8.com/?size=100&id=VJpqTKPYvnx2&format=png&color=000000
// @description  Removes front page carousel and mutes its audio
// @author       LiquidJesus
// @match        https://www.twitch.tv/*
// @grant        none
// @namespace https://greasyfork.org/users/1169082
// ==/UserScript==

(function() {
    'use strict';

    function removeCarousel() {
        // Look for any element that contains "carousel" in its class name
        const carousels = document.querySelectorAll('[class*="carousel"]');
        
        carousels.forEach(carousel => {
            // Only target elements on the front page that are likely the main carousel
            if (window.location.pathname === '/' || window.location.pathname === '') {
                // Hide the carousel
                carousel.style.display = 'none';
                
                // Mute any videos inside
                const videos = carousel.querySelectorAll('video');
                videos.forEach(video => {
                    video.muted = true;
                    video.pause();
                });
            }
        });
    }

    // Run on load
    removeCarousel();

    // Watch for changes and re-run
    new MutationObserver(removeCarousel).observe(document.body, {
        childList: true,
        subtree: true
    });
})();