Remove v2ex.com ad

Remove v2ex.com ads

  1. // ==UserScript==
  2. // @name Remove v2ex.com ad
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Remove v2ex.com ads
  6. // @author ficapy
  7. // @match https://www.v2ex.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=v2ex.com
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12. (() => {
  13. 'use strict';
  14. const targetNode = document.body;
  15. const config = { childList: true, subtree: true, attributes: true };
  16. const callback = function (mutationsList, observer) {
  17. for (const mutation of mutationsList) {
  18. if (mutation.type === 'childList' || mutation.type === 'attributes') {
  19. let nodesToCheck = mutation.addedNodes.length > 0 ? mutation.addedNodes : [mutation.target];
  20. nodesToCheck.forEach(node => {
  21. if (node.nodeType === 1) {
  22. const ads = node.querySelectorAll('.wwads-cn,.adsbygoogle');
  23. ads.forEach(ad => ad.style.display = 'none');
  24. }
  25. });
  26. let ad = document.querySelector('div.box > div > a[href="/advertise"]');
  27. if (ad){
  28. ad.parentNode.parentNode.style.display = 'none'
  29. }
  30. }
  31. }
  32. };
  33. const observer = new MutationObserver(callback);
  34. observer.observe(targetNode, config);
  35. document.querySelectorAll('.wwads-cn,.adsbygoogle').forEach(ad => ad.style.display = 'none');
  36. let ad = document.querySelector('div.box > div > a[href="/advertise"]');
  37. if (ad){
  38. ad.parentNode.parentNode.style.display = 'none'
  39. }
  40. })();

QingJ © 2025

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