tonybai去广告

脚本用于移除tonybai广告

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