remove anti-adblock for cnbeta

remove red alert top of cnbeta

  1. // ==UserScript==
  2. // @name remove anti-adblock for cnbeta
  3. // @namespace null
  4. // @version 1.2.4
  5. // @description remove red alert top of cnbeta
  6. // @author Anonymous
  7. // @match *://*.cnbeta.com/*
  8. // @grant none
  9. // @run-at document-start
  10. // ==/UserScript==
  11.  
  12. (function(){
  13. 'use strict';
  14. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  15. var clearAd = function clearAd(){
  16. var adNodes=document.querySelectorAll('a[href$="/articles/3.htm"]');
  17. if(adNodes.length>0){
  18. var ad=adNodes[0];
  19. var body=document.getElementsByTagName('body')[0];
  20. var adContainer=ad.parentNode.parentNode.parentNode;
  21. var mainContainer=adContainer.parentNode;
  22. mainContainer.removeChild(adContainer);
  23. body.style="";
  24. }
  25. };
  26. var observer = new MutationObserver(function(mutations) {
  27. mutations.forEach(function(mutation) {
  28. clearAd();
  29. });
  30. });
  31. var config = { attributes: true, childList: true, subtree: true, characterData: true };
  32. observer.observe(document, config);
  33. })();