bilibili直播默认最高画质(自定义延迟执行时间)

bilibili直播默认切换为最高画质(自定义延迟执行时间)

  1. // ==UserScript==
  2. // @name bilibili直播默认最高画质(自定义延迟执行时间)
  3. // @description bilibili直播默认切换为最高画质(自定义延迟执行时间)
  4. // @namespace https://github.com/PieJEed
  5. // @version 1.0.2
  6. // @author PieJEed
  7. // @match *://live.bilibili.com/*
  8. // @exclude *://live.bilibili.com/p/*
  9. // @icon https://www.bilibili.com//favicon.ico
  10. // @run-at document-start
  11. // @compatible chrome
  12. // @compatible firefox
  13. // @compatible edge
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. //延迟加载时间:修改“delay”的值(单位为ms,默认4000)
  18. const delay = 4000;
  19.  
  20. ;(function () {
  21. function process() {
  22. try {
  23. const livePlayer = document.querySelector('#live-player')
  24. livePlayer.dispatchEvent(new Event('mousemove'))
  25. const qualityWrap = livePlayer.querySelector('.quality-wrap')
  26. const observer = new MutationObserver(mutations => {
  27. mutations.some(mutation => {
  28. try {
  29. const qualities = mutation.target.querySelectorAll('.list-it')
  30. if (qualities.length) {
  31. qualities[0].click()
  32. livePlayer.dispatchEvent(new Event('mouseleave'))
  33. return true
  34. }
  35. return false
  36. } catch (e) {
  37. console.error(e)
  38. return false
  39. } finally {
  40. observer.disconnect()
  41. }
  42. })
  43. })
  44. observer.observe(qualityWrap, { childList: true, subtree: true })
  45. qualityWrap.dispatchEvent(new Event('mouseenter'))
  46. } catch (e) {
  47. console.error(e)
  48. }
  49. }
  50.  
  51. function live() {
  52. const observer = new MutationObserver(mutations => {
  53. mutations.forEach(mutation => {
  54. mutation.addedNodes.forEach(node => {
  55. if (node.nodeName === 'VIDEO') {
  56. window.setTimeout(process, delay)
  57. observer.disconnect()
  58. }
  59. })
  60. })
  61. })
  62. observer.observe(document, { childList: true, subtree: true })
  63. }
  64.  
  65. live()
  66. })()
  67.  
  68. // 此脚本是基于 [bilibili直播默认最高画质] 修改而来,遵循 MIT 协议。
  69. // 原始脚本地址:[https://gf.qytechs.cn/zh-CN/scripts/458957-bilibili%E7%9B%B4%E6%92%AD%E9%BB%98%E8%AE%A4%E6%9C%80%E9%AB%98%E7%94%BB%E8%B4%A8]
  70.  
  71. // 修改者:[PieJEed]
  72. // 修改日期:[20240110]
  73. // 修改内容:[为延迟加载时间添加变量;增加代码协议为 MIT ;修改脚本描述]

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址