wanwansub

wanwansub去广告

目前為 2020-08-22 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name wanwansub
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description wanwansub去广告
  6. // @author You
  7. // @match http://wanwansub.com/*
  8. // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let isrun = false;
  16. function noad() {
  17. if (isrun) return;
  18. console.log('noad');
  19. isrun = true;
  20. function subnoad(csspath) {
  21. const ad1 = $(csspath);
  22. if (ad1.length > 0)
  23. ad1.css('display', 'none');
  24. }
  25.  
  26. const ad1 = $('body > div:nth-child(5)');
  27. if (ad1.length == 0)
  28. {
  29. console.log('return noad');
  30. isrun = false;
  31. return;
  32. }
  33.  
  34. subnoad('body > div:nth-child(7)');
  35. subnoad('body > div:nth-child(6)');
  36. subnoad('body > div:nth-child(5)');
  37.  
  38. isrun = false;
  39. }
  40.  
  41. noad();
  42. //$('body').bind('DOMNodeInserted', noad);
  43. const config = { //attributes: true,
  44. childList: true,
  45. //subtree: true
  46. };
  47. const observer = new MutationObserver(noad);
  48. observer.observe($('body')[0], config);
  49. // Your code here...
  50. })();