// ==UserScript== // @name Bilibili - 自动切换直播画质至最高画质 // @namespace https://bilibili.com/ // @version 0.2 // @description 自动切换Bilibili直播画质至最高画质 | V0.2 新增在未登录状态下也能切换至最高画质的功能 // @license GPL-3.0 // @author DD1969 // @match https://live.bilibili.com/* // @icon https://www.bilibili.com/favicon.ico // @grant none // @downloadURL none // ==/UserScript== (async function() { 'use strict'; // override 'split' method of string to change the processing cookie string const originSplit = String.prototype.split; String.prototype.split = function (spliter) { let thisArg = this; if (spliter === ';' && this.length > 0) { thisArg = this + '; DedeUserID=123456'; } return originSplit.call(thisArg, spliter); } // wait until those essential variables/methods loaded await new Promise(resolve => { const timer = setInterval(() => { if (window.livePlayer && window.livePlayer.getPlayerInfo && window.livePlayer.switchQuality) { clearInterval(timer); resolve(); } }, 1000); }); if (window.livePlayer.getPlayerInfo().qualityCandidates.length === 0) return; window.livePlayer.switchQuality(window.livePlayer.getPlayerInfo().qualityCandidates[0].qn, ""); })();