哔哩哔哩自动打开字幕

bilibili b站 哔哩哔哩 自动打开网站字幕

  1. // ==UserScript==
  2. // @name 哔哩哔哩自动打开字幕
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-01-07
  5. // @description bilibili b站 哔哩哔哩 自动打开网站字幕
  6. // @author You
  7. // @match https://www.bilibili.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. let queryValue = '';
  17. // 定时检测URL是否发生变化
  18. let timer = setInterval(function() {
  19. // 获取URL中的查询字符串部分
  20. //const queryString = window.location.search;
  21. // 解析查询字符串,将参数以对象的形式存储
  22. //const params = new URLSearchParams(queryString);
  23. // 获取特定参数的值
  24. //const value = params.get('p');
  25.  
  26. const queryString = window.location.pathname;
  27. let params = queryString.split('/')
  28. let value = ''
  29. if (params[1] == 'list') {
  30. const qs = window.location.search;
  31. const p = new URLSearchParams(queryString);
  32. value = p.get('p');
  33. }else {
  34. value = params[2];
  35. }
  36. if (queryValue !== value) {
  37. openSubtitle();
  38. queryValue = value;
  39. }
  40. }, 2000);
  41.  
  42. window.addEventListener('unload', function(_event) {
  43. clearInterval(timer)
  44. });
  45.  
  46. function openSubtitle(){
  47. setTimeout(() => { document.querySelector('.bpx-player-ctrl-btn[aria-label="字幕"] .bpx-common-svg-icon').click(); }, 500)
  48. }
  49. // Your code here...
  50. })();

QingJ © 2025

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