矫正 b 站自动连播按钮 - 分P、合集、单视频开关分别独立

关于我不想要哔哩哔哩自动连播只想在分 P 中跳转但是阿 b 把他们混为一谈这件事。

  1. // ==UserScript==
  2. // @name 矫正 b 站自动连播按钮 - 分P、合集、单视频开关分别独立
  3. // @namespace https://maxchang.me
  4. // @version 0.4
  5. // @description 关于我不想要哔哩哔哩自动连播只想在分 P 中跳转但是阿 b 把他们混为一谈这件事。
  6. // @author MaxChang3
  7. // @match https://www.bilibili.com/video/*
  8. // @match https://www.bilibili.com/list/*
  9. // @icon https://www.bilibili.com/favicon.ico
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict'
  16. // 自定义 logger
  17. const logger = {
  18. log: (...args) => console.log('[Correct-Next-Button]', ...args),
  19. error: (...args) => console.error('[Correct-Next-Button]', ...args),
  20. }
  21. const type = { VIDEO: 'video', MULTIPART: 'multipart', COLLECTION: 'collection' }
  22. const correctNextButton = (app) => {
  23. const videoData = app.videoData
  24. const { videos: videosCount } = videoData
  25. const pageType = videosCount > 1 ? type.MULTIPART : (app.isSection ? type.COLLECTION : type.VIDEO)
  26. const pageStatus = app.continuousPlay
  27. const userStatus = GM_getValue(pageType)
  28. if (userStatus == undefined) {
  29. GM_setValue(pageType, pageStatus)
  30. } else if (pageStatus != userStatus) {
  31. app.setContinuousPlay(userStatus)
  32. }
  33. logger.log(pageType, {
  34. 'collection': GM_getValue(type.COLLECTION),
  35. 'multipart': GM_getValue(type.MULTIPART),
  36. 'video': GM_getValue(type.VIDEO)
  37. })
  38. document.querySelector('.switch-btn').addEventListener('click', () => {
  39. GM_setValue(pageType, !app.continuousPlay)
  40. })
  41. }
  42. const main = () => {
  43. if (location.href.startsWith('https://www.bilibili.com/medialist/play/')) {
  44. // todo
  45. } else {
  46. let interval = setInterval(() => {
  47. let app = document.querySelector('#app')
  48. if (app?.__vue__?.videoData) {
  49. clearInterval(interval)
  50. correctNextButton(app.__vue__)
  51. // hook loadVideoData 保证从推荐视频加载新视频时重新判断视频类型
  52. const __loadVideoData = app.__vue__.loadVideoData
  53. app.__vue__.loadVideoData = () => new Promise((resolve, rejct) =>
  54. __loadVideoData.call(this).then(
  55. res => { correctNextButton(app.__vue__); resolve(res) },
  56. error => rejct(error)
  57. )
  58. )
  59. }
  60. }, 500)
  61. }
  62. }
  63. main()
  64. })()

QingJ © 2025

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