虎牙自动最高画质

默认跳过部分直播间存在的HDR播放源,需要的同学自行将代码中hdr=false改为true

// ==UserScript==
// @name         虎牙自动最高画质
// @description  默认跳过部分直播间存在的HDR播放源,需要的同学自行将代码中hdr=false改为true
// @author       shopkeeperV
// @namespace    https://greasyfork.org/zh-CN/users/150069
// @version      0.3
// @match        *://*.huya.com/*
// @noframes
// ==/UserScript==

(function() {
    let hdr = false;
    let timer;
    let toggle = function() {
        const videotypes = document.querySelector('.player-videotype-list');
        if (!videotypes) return;
        let index = 0;
        for (let i = 0; i < videotypes.children.length; i++) {
            if (!hdr && videotypes.children[index].textContent.includes("HDR")) index++;
            else break;
        }
        let highest = videotypes.children[index];
        if (highest.className === 'on') return;
        highest.click();
        clearInterval(timer);
    };
    timer = setInterval(toggle, 1000);
})();