jsKillAD

查杀页面浮动广告

  1. // ==UserScript==
  2. // @name jsKillAD
  3. // @namespace jsKillAD
  4. // @description 查杀页面浮动广告
  5. // @author xinggsf~gmail。com
  6. // @homepageURL https://greasyfork.org/scripts/7410
  7. // updateURL https://greasyfork.org/scripts/7410.js
  8. // @encoding utf-8
  9. // @license GPL version 3
  10. // @include http://*
  11. // @include https://*
  12. // @exclude http://*.mail.*/*
  13. // @exclude http://mail.*
  14. // @exclude https://mail.*
  15. // @exclude http://*mimg.127.net/*
  16. // @exclude http://*.csdn.net/postedit/*
  17. // @exclude *://www.google.*/search?*
  18. // @exclude *://www.google.*/webhp*
  19. // @exclude *://pan.baidu.com/*
  20. // @exclude *://www.baidu.com/*
  21. // @exclude *://yun.baidu.com/*
  22. // @exclude *://play.baidu.com/*
  23. // @exclude http://115.com/*
  24. // @exclude http://*.115.com/*
  25. // @exclude http://*.1ting.com/*
  26. // @exclude http://www.360doc.com/*
  27. // @exclude *://www.cnblogs.com/*
  28. // @exclude http://www.iqiyi.com/v_*
  29. // @exclude *://*.qq.com/*
  30. // @exclude http://video.sina.com.cn/*
  31. // @exclude http://www.yatu.tv/m*/play*.html
  32. // @grant none
  33. // @version 2015.9.1
  34. // ==/UserScript==
  35. -function(doc) {
  36. var tags = ['iframe', 'img', 'object', 'embed', 'video'];
  37.  
  38. function getStyle(o, s) {
  39. if (o.style[s]) return o.style[s];
  40. if (doc.defaultView && doc.defaultView.getComputedStyle) { //DOM
  41. var x = doc.defaultView.getComputedStyle(o, '');
  42. //s = s.replace(/([A-Z])/g,'-$1').toLowerCase();
  43. return x && x.getPropertyValue(s);
  44. }
  45. }
  46. function testStyle(o) {
  47. var s = getStyle(o, 'position');
  48. return s === 'fixed' || s === 'absolute';
  49. }
  50. function isFloatLay(o) {
  51. var x = o.offsetParent;
  52. return !x || x.tagName === 'BODY' || x.tagName === 'HTML';
  53. }
  54.  
  55. tags.forEach(function (s) {
  56. tags.forEach.call(doc.getElementsByTagName(s), function (x) {
  57. while (x) {
  58. if (isFloatLay(x)) {
  59. testStyle(x) && x.parentNode.removeChild(x);
  60. break;
  61. }
  62. x = x.offsetParent;
  63. }
  64. });
  65. });
  66. }(document);