动漫花园自定义屏蔽字幕组

在脚本菜单中添加自定义屏蔽字幕组功能

  1. // ==UserScript==
  2. // @name 动漫花园自定义屏蔽字幕组
  3. // @author ChatGPT
  4. // @version 1.1
  5. // @description 在脚本菜单中添加自定义屏蔽字幕组功能
  6. // @match https://share.dmhy.org/*
  7. // @grant GM_registerMenuCommand
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // @run-at document-end
  11. // @namespace https://gf.qytechs.cn/users/452911
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. // 添加菜单函数
  16. function addMenu() {
  17. var keyword = prompt("请输入要屏蔽的关键词,多个关键词用英文逗号分隔", GM_getValue('blockedKeywords', ''));
  18. if (keyword !== null) {
  19. GM_setValue('blockedKeywords', keyword);
  20. blockElements(keyword);
  21. }
  22. }
  23.  
  24. // 屏蔽包含关键词的元素
  25. function blockElements(keywordString) {
  26. var keywords = keywordString.split(',');
  27. var elements = document.querySelectorAll('tr.odd, tr.even');
  28.  
  29. for (var i = 0; i < elements.length; i++) {
  30. var element = elements[i];
  31. var shouldHide = false;
  32.  
  33. for (var j = 0; j < keywords.length; j++) {
  34. if (element.textContent.includes(keywords[j].trim())) {
  35. shouldHide = true;
  36. break;
  37. }
  38. }
  39.  
  40. if (shouldHide) {
  41. element.style.display = 'none';
  42. } else {
  43. element.style.display = '';
  44. }
  45. }
  46. }
  47.  
  48. // 添加菜单
  49. GM_registerMenuCommand("自定义屏蔽关键词", addMenu);
  50.  
  51. // 页面加载时隐藏包含关键词的元素
  52. var blockedKeywords = GM_getValue('blockedKeywords', '');
  53. if (blockedKeywords !== '') {
  54. blockElements(blockedKeywords);
  55. }
  56. })();
  57.  

QingJ © 2025

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