网易有道网页绿化

去广告、网页绿化

  1. // ==UserScript==
  2. // @name 网易有道网页绿化
  3. // @namespace http://tampermonkey.net/
  4. // @match https://www.youdao.com/*
  5. // @grant unsafeWindow
  6. // @run-at document-start
  7. // @version 1.0
  8. // @license MIT
  9. // @author Berger
  10. // @description 去广告、网页绿化
  11. // ==/UserScript==
  12. (function () {
  13. "use strict";
  14.  
  15. class PageUtils {
  16. static removeElement(element) {
  17. if (element) {
  18. element.remove()
  19. }
  20. }
  21.  
  22. static removeElementWithCheck(className) {
  23. this.checkElement(className, function (element) {
  24. PageUtils.removeElement(element)
  25. })
  26. }
  27.  
  28. static checkElement(className, callback) {
  29. const observer = new MutationObserver(function (mutationsList, observer) {
  30. const element = document.querySelector(className);
  31. if (element) {
  32. observer.disconnect();
  33. callback(element)
  34. }
  35. });
  36.  
  37. observer.observe(document.body, {childList: true, subtree: true});
  38. }
  39. }
  40.  
  41. class PageConcise {
  42. // 顶部广告
  43. static topBanner() {
  44. PageUtils.removeElementWithCheck('div.top-banner-wrap')
  45. }
  46.  
  47. // 产品宣传区域
  48. static productContainer() {
  49. PageUtils.removeElementWithCheck('div.product-container')
  50. }
  51.  
  52. // 单词详情页页脚
  53. static vocabularyInfoPageFooter() {
  54. const footerDiv = document.querySelector('div.footer_container')
  55. PageUtils.removeElement(footerDiv)
  56. }
  57.  
  58. // 单词详情页广告
  59. static translateInfoAD() {
  60. PageUtils.removeElementWithCheck('div.dict-module > div[disable-zoom]')
  61. }
  62.  
  63. // 单词搜索页页脚
  64. static vocabularySearchPageFooter() {
  65. PageUtils.removeElementWithCheck('div.dict-website-footer-container')
  66. }
  67.  
  68. // 用户反馈
  69. static feedbackDiv(){
  70. PageUtils.removeElementWithCheck('div.user-feed_back')
  71. }
  72. }
  73.  
  74. const main = {
  75. initPage() {
  76. // 顶部广告
  77. PageConcise.topBanner()
  78. // 产品宣传区域
  79. PageConcise.productContainer()
  80. // 单词详情页页脚
  81. PageConcise.vocabularyInfoPageFooter()
  82. // 单词详情页广告
  83. PageConcise.translateInfoAD()
  84. // 单词搜索页页脚
  85. PageConcise.vocabularySearchPageFooter()
  86. // 用户反馈
  87. PageConcise.feedbackDiv()
  88. }
  89. }
  90.  
  91. // 监听 DOMContentLoaded 事件
  92. window.addEventListener('DOMContentLoaded', main.initPage);
  93.  
  94. // 监听 popstate 事件
  95. window.addEventListener('popstate', main.initPage);
  96.  
  97. window.addEventListener('load', main.initPage);
  98. })()

QingJ © 2025

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