rule4video移除广告

ttt

  1. // ==UserScript==
  2. // @name rule4video移除广告
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-01-29
  5. // @description ttt
  6. // @author You
  7. // @match https://rule34video.com/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=rule34video.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12.  
  13.  
  14. (function () {
  15. 'use strict';
  16.  
  17. // 过滤函数
  18. function filterVideos() {
  19. // 获取id为custom_list_videos_most_recent_videos_items的div元素
  20. const parentDiv = document.getElementById('custom_list_videos_most_recent_videos_items');
  21.  
  22. if (parentDiv) {
  23. // 获取parentDiv的所有子div元素
  24. const childDivs = parentDiv.querySelectorAll('div');
  25.  
  26. childDivs.forEach(childDiv => {
  27. // 检查子div是否包含header标签
  28. const header = childDiv.querySelector('header');
  29.  
  30. if (header) {
  31. // 如果包含header标签,则移除该子div
  32. childDiv.remove();
  33. }
  34. });
  35. }
  36. }
  37.  
  38. // 初始执行一次
  39. filterVideos();
  40.  
  41. // 监听DOM变化
  42. const observer = new MutationObserver((mutations) => {
  43. mutations.forEach(mutation => {
  44. // 检查是否有节点被添加
  45. if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
  46. // 重新执行过滤逻辑
  47. filterVideos();
  48. }
  49. });
  50. });
  51.  
  52. // 开始观察整个文档的变化
  53. observer.observe(document.body, {
  54. childList: true, // 观察子节点的变化
  55. subtree: true, // 观察所有后代节点
  56. });
  57. })();