tonybai去广告

脚本用于移除tonybai广告

  1. // ==UserScript==
  2. // @name tonybai-adb
  3. // @name:zh-CN tonybai去广告
  4. // @name:zh-TW tonybai去廣告
  5. // @name:zh-HK tonybai去廣告
  6. // @name:zh-MO tonybai去廣告
  7. // @namespace Violentmonkey Scripts
  8. // @match https://tonybai.com/*
  9. // @grant none
  10. // @version 1.4
  11. // @author ddatsh
  12. // @description A script to remove tonybai ads
  13. // @description:zh-CN 脚本用于移除tonybai广告
  14. // @description:zh-TW 腳本用於移除 tonybai 廣告
  15. // @description:zh-HK 腳本用於移除 tonybai 廣告
  16. // @description:zh-MO 腳本用於移除 tonybai 廣告
  17. // ==/UserScript==
  18.  
  19. (function() {
  20. `use strict`;
  21.  
  22. // 获取所有的<article>元素
  23. const articles = document.querySelectorAll('article');
  24.  
  25. articles.forEach(article => {
  26. // 查找<article>中所有的<hr>元素
  27. const hrs = article.querySelectorAll('hr');
  28.  
  29. if (hrs.length > 0) {
  30. // 获取最后一个<hr>元素
  31. const lastHr = hrs[hrs.length - 1];
  32.  
  33. // 从最后一个<hr>元素开始,删除到<article>结束的所有内容
  34. while (lastHr.nextSibling) {
  35. lastHr.parentNode.removeChild(lastHr.nextSibling);
  36. }
  37. // 删除最后一个<hr>元素
  38. lastHr.parentNode.removeChild(lastHr);
  39. }
  40. });
  41.  
  42. // 获取包含section元素的父容器
  43. var parentDiv = document.getElementById('secondary');
  44. parentDiv.style.paddingTop = '0';
  45.  
  46. var firstWidgetSection = parentDiv.querySelector('section.widget');
  47.  
  48. // 如果找到该元素,从DOM中移除
  49. if (firstWidgetSection) {
  50. firstWidgetSection.parentNode.removeChild(firstWidgetSection);
  51. }
  52.  
  53. // 单独查找并移除具有特定ID的section元素
  54. var sectionText4 = document.getElementById('text-4');
  55. if (sectionText4) {
  56. sectionText4.parentNode.removeChild(sectionText4);
  57. }
  58.  
  59. var sectionText3 = document.getElementById('text-3');
  60. if (sectionText3) {
  61. sectionText3.parentNode.removeChild(sectionText3);
  62. }
  63. var wpm_subscribe_widget = document.getElementById('wpm_subscribe_widget-3');
  64. if (sectionText3) {
  65. wpm_subscribe_widget.parentNode.removeChild(wpm_subscribe_widget);
  66. }
  67. })();