Rumble - Auto Force Lowest Quality (Adaptive Final)

FINAL ADAPTIVE SOLUTION: Uses the proven interval logic and loops through quality options to skip 'Auto' and guarantee lowest resolution selection.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Rumble - Auto Force Lowest Quality (Adaptive Final)
// @namespace    rumble-automation
// @version      14.0
// @description  FINAL ADAPTIVE SOLUTION: Uses the proven interval logic and loops through quality options to skip 'Auto' and guarantee lowest resolution selection.
// @author       Gemini
// @license      MIT
// @match        *://rumble.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let $url = "";
    let $click_times = 0;

    const simpleClick = (target, a) => {
        if(target){
            target.click();
        }
        if(a){
            $click_times++;
        }
    };

    const rumbleQualityInterval = setInterval(() => {
        let currentUrl = document.URL;

        if(currentUrl !== $url || $click_times < 3){
            try{
                // *** 1. PROVEN TRAVERSAL (Gear Icon/Menu Container) ***
                let playback = document.getElementsByClassName("touched_overlay_item")[0].nextElementSibling.lastChild.lastChild;

                // Get the Gear Icon
                let gearIcon = playback.firstChild;

                // *** 2. CLICK GEAR ICON ***
                simpleClick(gearIcon);

                // *** 3. CLICK LOWEST RESOLUTION (Adaptive) ***

                // Get the Resolution List container (UL element)
                let resolutionList = playback.lastChild.lastChild;

                // Loop through all *element* children (LI tags) to find the lowest quality option
                let lowestQualityOption = null;

                // Use .children to get only element nodes (<li>) and ignore text nodes
                for (let i = 0; i < resolutionList.children.length; i++) {
                    let option = resolutionList.children[i];
                    let text = option.textContent.trim().toLowerCase();

                    // Skip the 'Auto' option. The first option that is NOT 'Auto' is the lowest resolution stream.
                    if (text.includes("auto")) {
                        continue;
                    }

                    // This is the desired lowest resolution stream
                    lowestQualityOption = option;
                    break;
                }

                if (lowestQualityOption) {
                    simpleClick(lowestQualityOption, true);
                    console.log(`Rumble Auto Quality: SUCCESSFULLY FORCED to lowest available (${lowestQualityOption.textContent.trim()}).`);
                }

            } catch(e) {
                // Failure is expected when the menu is not yet loaded/rendered
            }

            // *** 4. LOOP BREAK CONDITION ***
            if($click_times >= 3){
                $click_times = 0;
                $url = currentUrl;
                clearInterval(rumbleQualityInterval);
            }
        }
    }, 500);
})();