jsKillAD

查杀页面浮动广告

Από την 18/01/2015. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        jsKillAD
// @namespace   jsKillAD
// @description 查杀页面浮动广告
// @description:en Kill AD on page
// @author	    xinggsf
// @homepageURL https://greasyfork.org/scripts/7410
// updateURL    https://greasyfork.org/scripts/7410/code/jsKillAD.user.js
// downloadURL  https://greasyfork.org/scripts/7410/code/jsKillAD.user.js
// @encoding    utf-8
// @modified    01/12/2015
// @include     http://*
// @include     https://*
// @exclude     http://*.mail.*/*
// @exclude     http://*mimg.127.net/*
// @exclude     http://*.csdn.net/postedit/*
// @exclude     http*://www.google.*/search?q=*
// @exclude     http://www.baidu.com/s?*
// @exclude     http://*share*.qq.com/*
// @exclude     http://video.sina.com.cn/*
// @exclude     http://*.1ting.com/*
// @exclude     http://*.gsmn.com.cn/*
// @exclude     http://*115.com/*
// @exclude     http://quote.futures.hexun.com/price.aspx?*
// @run-at      document-end
// @grant       none
// @version     1.3
// ==/UserScript==
(function () {
  var bc = Array.prototype.forEach; //Callback
  
  function getStyle(o, s) {
    if (o.style[s]) { //内联样式
      return o.style[s];
    }
    if (document.defaultView && document.defaultView.getComputedStyle) { //DOM
      //s = s.replace(/([A-Z])/g,'-$1').toLowerCase();
      var x = document.defaultView.getComputedStyle(o, '');
      return x && x.getPropertyValue(s);
    }
  }
  
  function testStyle(o) {
    var s = getStyle(o, 'position');
    return s === 'fixed' || s === 'absolute';
  }
  function isFloatLay(o) {
    var x = o.offsetParent;
    return !x || x.tagName === 'BODY' || x.tagName === 'HTML';
  }
  function delNode(x) {
    x.parentNode.removeChild(x);
  }
  
  function scan(el) {
    ['iframe','img','object','embed'].forEach(function (s) {
      bc.call(el.getElementsByTagName(s), function (x) {
        while (x) {
          if (isFloatLay(x)) {
            //要删除的层得同时满足二个条件
            if (testStyle(x)) {delNode(x);}
            break;
          }//else
          x = x.offsetParent;
        }
      });
    });
  }
  
  //document.addEventListener("DOMContentLoaded", function(){scan(document);}, false);
  scan(document);
  bc.call(frames, function (x) {
    try {scan(x.contentDocument);} 
    catch (e) {}
  });
}) ();