fdesouche.com popup ad remover

This script remove ad and anti adblock popups on fdesouche.com

目前为 2015-12-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name fdesouche.com popup ad remover
  3. // @namespace http://userscripts.org/users/useridnumber
  4. // @description This script remove ad and anti adblock popups on fdesouche.com
  5. // @include http://*.fdesouche.com/*
  6. // @include http://fdesouche.com/*
  7. // @version 2
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. var removeads = function removeads () {
  12. var items = {};
  13. var selects = jQuery("a[href^='http://lc.cx/']");
  14. selects.each(function (_, e) {
  15. var pNode = e.parentNode
  16. while (pNode.parentNode.nodeName === "DIV" && pNode.parentNode.className !== "") {
  17. pNode = pNode.parentNode;
  18. }
  19. pNode.parentNode.removeChild(pNode);
  20. });
  21. }
  22.  
  23. removeads();
  24.  
  25. // Create an observer instance
  26. var observer = new MutationObserver(function( mutations ) {
  27. mutations.forEach(function( mutation ) {
  28. var newNodes = mutation.addedNodes; // DOM NodeList
  29. if( newNodes !== null ) { // If there are new nodes added
  30. var selects = jQuery("body>div>h1");
  31. if (selects.length !== 0) {
  32. var node = selects[0];
  33. if (node.innerHTML.indexOf("Adblock") !== -1) {
  34. node = node.parentNode;
  35. node.style.visibility="hidden";
  36. document.__fds_popupClassName = node.className + "-bg";
  37. console.info("CAP:" + document.__fds_popupClassName);
  38. }
  39. }
  40. var selects = jQuery("body>div." + document.__fds_popupClassName);
  41. if (selects.length !== 0) {
  42. selects[0].style.visibility="hidden";
  43. }
  44. }
  45. });
  46. });
  47.  
  48. // Configuration of the observer:
  49. var config = {
  50. attributes: true,
  51. childList: true,
  52. characterData: true
  53. };
  54. // Pass in the target node, as well as the observer options
  55. observer.observe(document.body, config);