Greasy Fork

来自缓存

Greasy Fork is available in English.

虎牙自动最高码率 (免登录), 屏蔽 PCDN

将默认码率调到最高码率 (可突破扫码专享, 实测最高到蓝光 20M), 并屏蔽 PCDN, 防止偷跑上传

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         虎牙自动最高码率 (免登录), 屏蔽 PCDN
// @namespace    http://tampermonkey.net/
// @version      1.1.0
// @description  将默认码率调到最高码率 (可突破扫码专享, 实测最高到蓝光 20M), 并屏蔽 PCDN, 防止偷跑上传
// @author       浩劫者12345
// @match        https://*.huya.com/*
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    // 屏蔽 PCDN (禁用 WebRTC)
    if (window.RTCPeerConnection) {
        const log = console.log
        const origRTCPeerConnection = window.RTCPeerConnection

        class HookedRTCPeerConnection {
            constructor(config) {
                log('Blocking WebRTC connection:', JSON.stringify(config))
                throw new Error('WebRTC is disabled by userscript')
                return new origRTCPeerConnection(config)
            }
        }

        window.RTCPeerConnection = HookedRTCPeerConnection
        window.webkitRTCPeerConnection = window.RTCPeerConnection
        window.mozRTCPeerConnection = window.RTCPeerConnection
    }


    // 设置 cookie 中上次使用的码率
    document.cookie = 'videoBitRate=99999; domain=.huya.com'
    console.log('Set last used bitrate to 99999')

    // 伪装登录状态
    if (!document.cookie.includes('yyuid=')) {
        document.cookie = 'yyuid=1; domain=.huya.com'
        console.log('Set logged in status')
    }

    // 拦截页面内 JS 对 hyPlayerConfig 的赋值, 修改 iWebDefaultBitRate (默认码率)
    let _hyPlayerConfig = {};

    Object.defineProperty(window, 'hyPlayerConfig', {
        get() {
            return _hyPlayerConfig
        },
        set(newValue) {
            Object.assign(_hyPlayerConfig, newValue)

            if (_hyPlayerConfig.stream) {
                _hyPlayerConfig.stream.iWebDefaultBitRate = 99999
                console.log('Hook set `hyPlayerConfig.stream.iWebDefaultBitRate` to', window.hyPlayerConfig.stream.iWebDefaultBitRate)
            }
        }
    })
})();