Greasy Fork

Greasy Fork is available in English.

虎牙直播自动切换画质

功能:虎牙直播自动切换最高画质、自动切换指定画质

当前为 2025-07-17 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         虎牙直播自动切换画质
// @description  功能:虎牙直播自动切换最高画质、自动切换指定画质
// @namespace    https://github.com/psa1K
// @icon         https://www.huya.com/favicon.ico
// @version      1.0.0
// @author       psa1K
// @match        *://*.huya.com/*
// @grant        none
// @license      WTFPL
// @noframes
// ==/UserScript==

(function () {
  const switchToTopQuality = setInterval(() => {
    const $cur = $(".player-videotype-cur");
    const $list = $(".player-videotype-list li");

    if ($cur.length === 0 || $list.length === 0) return;

    if ($cur.text().trim() !== $list.first().text().trim()) {
      $list.first().click();
    } else {
      clearInterval(switchToTopQuality);
    }
  }, 1000);
})();

//如果你希望自动切换到特定的画质,只需将下面的 targetQuality 参数设置为你想要的画质,并删除其他多余的代码,然后取消注释以下代码即可。
/*
(function () {
    const targetQuality = '蓝光4M';//修改此处
    const switchToTopQuality = setInterval(() => {
        if ($('.player-videotype-cur').length === 0 || $('.player-videotype-list li').length === 0) return;

        if ($('.player-videotype-cur').text().trim() === targetQuality) {
            clearInterval(switchToTopQuality);
            return;
        }

        const $match = $('.player-videotype-list li').filter((_, el) => $(el).text().trim() === targetQuality);
        if ($match.length > 0) {
            $match.click();
            clearInterval(switchToTopQuality);
        }
    }, 1000);
})();
*/