BiliAuto

B站快捷键扩展 自动关闭顶栏 自动宽屏 2倍速c 减速x 1倍速z

  1. // ==UserScript==
  2. // @name BiliAuto
  3. // @version 24.8.15
  4. // @author mishi321
  5. // @description B站快捷键扩展 自动关闭顶栏 自动宽屏 2倍速c 减速x 1倍速z
  6. // @match https://www.bilibili.com/video/*
  7. // @grant GM_getValue
  8. // @grant GM_setValue
  9. // @grant GM_registerMenuCommand
  10. // @grant GM_unregisterMenuCommand
  11. // @namespace https://gf.qytechs.cn/scripts/428878
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. (() => {
  16. const style = document.createElement("style");
  17. const 播放器右下方广告 = ".ad-report {display: none !important;}";
  18. const 宽屏模式创作团队高度调整 = `
  19. .video-info-container[data-v-5120f6b9] {height: 108px !important; padding-top: 22px !important;}
  20. .header {display: none !important;}
  21. .members-info-container {padding-top: 14px !important;}
  22. .membersinfo-upcard-wrap {padding-bottom: 10px !important;}
  23. .bili-danmaku-x-guide-all.bili-danmaku-x-guide.bili-danmaku-x-show {display: none !important;}`;
  24. const 隐藏顶栏 = "#biliMainHeader {display: none !important;}";
  25. style.innerHTML += 播放器右下方广告 + 宽屏模式创作团队高度调整;
  26.  
  27. const headerClose = GM_getValue("headerClose");
  28. if (headerClose === true) {
  29. style.innerHTML += 隐藏顶栏;
  30. }
  31. GM_registerMenuCommand(`自动关闭顶栏:${headerClose}`, () => {
  32. GM_setValue("headerClose", !headerClose);
  33. });
  34.  
  35. let speedIndex = 3;
  36. const widescreenOn = GM_getValue("widescreenOn");
  37. GM_registerMenuCommand(`自动宽屏:${widescreenOn}`, () => {
  38. GM_setValue("widescreenOn", !widescreenOn);
  39. window.location.reload();
  40. });
  41. document.body.addEventListener("keydown", (e) => {
  42. if (e.target.nodeName !== "BODY") return;
  43. if (e.ctrlKey === false) {
  44. switch (e.key) {
  45. case "c":
  46. speedIndex = 0;
  47. document
  48. .getElementsByClassName("bpx-player-ctrl-playbackrate-menu-item")
  49. [speedIndex].click();
  50. break;
  51. case "x":
  52. if (speedIndex < 5) {
  53. speedIndex += 1;
  54. }
  55. document
  56. .getElementsByClassName("bpx-player-ctrl-playbackrate-menu-item")
  57. [speedIndex].click();
  58. break;
  59. case "z":
  60. speedIndex = 3;
  61. document
  62. .getElementsByClassName("bpx-player-ctrl-playbackrate-menu-item")
  63. [speedIndex].click();
  64. break;
  65. default:
  66. break;
  67. }
  68. }
  69. });
  70.  
  71. document.head.append(style);
  72.  
  73. const video = document.getElementsByTagName("video")[0];
  74. let src = "";
  75. video.addEventListener("playing", () => {
  76. console.log("playing");
  77. if (video.src !== src) {
  78. console.log("src change");
  79. const ev1 = setInterval(() => {
  80. if (video.volume === 0) {
  81. document
  82. .getElementsByClassName("bpx-player-ctrl-muted-icon")[0]
  83. .click();
  84. }
  85. if (widescreenOn === true) {
  86. if (
  87. document.getElementsByClassName("bpx-state-entered")[0] ===
  88. undefined
  89. ) {
  90. document.getElementsByClassName("bpx-player-ctrl-wide")[0].click();
  91. }
  92. setTimeout(() => {
  93. window.scrollTo({
  94. top: 0,
  95. });
  96. }, 2000);
  97. }
  98. clearInterval(ev1);
  99. src = video.src;
  100. }, 200);
  101. }
  102. });
  103. })();

QingJ © 2025

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