bilibili BufferTime Change

BufferTime Set 250s

As of 2023-08-05. See the latest version.

// ==UserScript==
// @name         bilibili BufferTime Change
// @version      0.0.1
// @description  BufferTime Set 250s
// @author       Vanisoul
// @match        https://www.bilibili.com/*
// @license      MIT
// @namespace https://greasyforks.org/users/429936
// ==/UserScript==

window.addEventListener('DashPlayerReady', function(e) {
  const DashPlayer = e.detail;
  const origFire = DashPlayer.prototype.fire;
  DashPlayer.prototype.fire = function (...args) {
      console.log(`BufferLength : ${this.player.getBufferLength()}`);
      if (this.player.getStableBufferTime() !== 250) {
          this.player.setBufferPruningInterval(3);
          this.player.setStableBufferTime(250);
          this.player.setBufferTimeAtTopQuality(250);
          this.player.setBufferTimeAtTopQualityLongForm(250);
          this.player.setBufferAheadToKeep(250 + 10);
          this.player.setBufferToKeep(30000);
          console.log("hook set buffer time 250");
      }
      origFire.apply(this, args)
  }
});

// Tampermonkey 無法直接存取 Window 物件
var script = document.createElement("script");
var checkDashPlayerIntervalFunction = function () {
    if (window.DashPlayer) {
        var event = new CustomEvent('DashPlayerReady', { detail: window.DashPlayer });
        window.dispatchEvent(event);
        clearInterval(window.checkDashPlayerInterval);
    }
};
script.innerHTML = `window.checkDashPlayerInterval = setInterval(${checkDashPlayerIntervalFunction}, 100);`;
document.head.appendChild(script);
长期地址
遇到问题?请前往 GitHub 提 Issues。