BiliBili视频助手

BiliBili视频助手,提供自动宽屏、自动洗脑循环等功能

  1. // ==UserScript==
  2. // @name BiliBili视频助手
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.2
  5. // @description BiliBili视频助手,提供自动宽屏、自动洗脑循环等功能
  6. // @author tuntun
  7. // @match https://www.bilibili.com/video/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. const _historyWrap = function(type) {
  16. const orig = history[type];
  17. const e = new Event(type);
  18. return function() {
  19. const rv = orig.apply(this, arguments);
  20. e.arguments = arguments;
  21. window.dispatchEvent(e);
  22. return rv;
  23. };
  24. };
  25. history.pushState = _historyWrap('pushState');
  26. history.replaceState = _historyWrap('replaceState');
  27.  
  28. const isAutoWidescreen = false;
  29. let firstVisible = true;
  30. const repeat = (time = 0) => {
  31. setTimeout(()=> {
  32. let setting = document.querySelector('.bilibili-player-video-btn-setting');
  33. if (setting !== null) {
  34. const event1 = new MouseEvent('mouseover');
  35. setting.dispatchEvent(event1);
  36. let btn = document.querySelector('.bilibili-player-video-btn-setting-left-repeat input');
  37. // console.dir(btn)
  38. if (!btn.checked) {
  39. btn.click();
  40. // console.log('repeat')
  41. }
  42. const event2 = new MouseEvent('mouseout');
  43. setting.dispatchEvent(event2);
  44. if (firstVisible) {
  45. firstVisible = !firstVisible;
  46. }
  47. }
  48. }, time);
  49. }
  50. const widescreen = (time = 0) => {
  51. // console.log('widescreen');
  52. if (isAutoWidescreen) {
  53. setTimeout(()=> {
  54. let widescreenBtn = document.querySelector('.bilibili-player-video-btn-widescreen');
  55. widescreenBtn.click();
  56. }, time);
  57. }
  58. }
  59. window.addEventListener(
  60. 'load',
  61. async () => {
  62. repeat(3000);
  63. },
  64. false,
  65. )
  66. document.addEventListener("visibilitychange", function() {
  67. if (document.visibilityState === 'visible' && firstVisible) {
  68. // console.log(document.visibilityState);
  69. widescreen(1500)
  70. repeat(3000);
  71. firstVisible = !firstVisible;
  72. }
  73. });
  74. let preBv = location.pathname;
  75. // console.log(preBv);
  76. window.addEventListener('pushState', function(e) {
  77. const newBv = e.arguments[2].slice(0, 19);
  78. // console.log(newBv);
  79. repeat();
  80. if(preBv !== newBv){
  81. widescreen();
  82. preBv = newBv;
  83. }
  84. });
  85. window.addEventListener('popstate', function(event) {
  86. repeat();
  87. widescreen();
  88. })
  89. })();

QingJ © 2025

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