Greasy Fork

来自缓存

Greasy Fork is available in English.

虎牙解锁蓝光20M清晰度

免扫码免登录解锁虎牙直播所有清晰度(包括蓝光20M)。修改自477947-虎牙免登录观看。

当前为 2025-06-05 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         虎牙解锁蓝光20M清晰度
// @description  免扫码免登录解锁虎牙直播所有清晰度(包括蓝光20M)。修改自477947-虎牙免登录观看。
// @author       L based on (σ`д′)σ
// @version      1.0.0
// @namespace    http://greasyfork.icu/zh-CN/users/1069880-l-l
// @license      GPL-3.0-or-later
// @match        *://www.huya.com/*
// // @include    /^https:\/\/www\.huya\.com\/[^/]+\/?$/
// @run-at       document-end
// ==/UserScript==

/*
 * 基于原脚本 http://greasyfork.icu/zh-CN/scripts/477947 修改。
 * 原作者: (σ`д′)σ
 * 依据 GPL-3.0-or-later 许可证进行分发。
 */


(() => {
  'use strict';

  // 获取元素通过ID
  const getById = (id) => document.getElementById(id);


  // 解锁视频清晰度
  function unlockResolution() {
    const $vtList = $('#player-ctrl-wrap .player-videotype-list');
    if (!$vtList.length) return;

    const unlockRES = () => {
      const $highRes = $vtList.children(':has(.bitrate-right-btn.common-enjoy-btn)');
      if ($highRes.length) {
        $highRes.each((i, e) => {
          $(e).data('data').status = 0;
          // 自动选择最高清晰度
          if (i === 0) {
            setTimeout(() => e.click(), 0);
          }
        });
      } else if ($vtList.children().length > 1) {
        $vtList.children()[0].click();
      }
    };

    // 观察视频清晰度列表变化
    new MutationObserver(unlockRES).observe($vtList[0], {
      attributes: false,
      childList: true,
      subtree: false
    });
    unlockRES();
  }

  // 初始化,等待播放器控件加载
  new MutationObserver((mutations, ob) => {
    const playerCtrlWrap = getById('player-ctrl-wrap');
    if (playerCtrlWrap) {
      unlockResolution();
      ob.disconnect();
    }
  }).observe(document.body, {
    attributes: false,
    childList: true,
    subtree: false
  });
})();