屏蔽百度广告的脚本

需要先安装TrixIE http://www.bhelpuri.net/Trixie/

然后把脚本拷贝到 C:/Program Files/Bhelpuri/Trixie/Scripts

// Copyright (c) 2006 TravelInHistory
// This script is licensed under the MIT license.  See
// http://opensource.org/licenses/mit-license.php for more details.
//
// ==UserScript==
// @name          Remove Baidu Ad
// @namespace     http://www.bhelpuri.net/Trixie
// @description   Remove Baidu's Ad on the right
// @include       http://www.baidu.com/*
// ==/UserScript==

//
// Discussion forum: http://groups.yahoo.com/group/trixieUsers/
//

(function()
{
   
 var tables = document.getElementsByTagName("table");

 for (var i = 0; i < tables.length; ++i)
 {
  var node = tables[i];
  var align = node.getAttribute("align");
        if (align == "right")
        {
            var par = node.parentNode;
            par.removeChild(node);
        }
    }
    var links = document.getElementsByTagName("a");
    var toRemove = Array();
    for (var i = 0; i <= links.length; ++i)
    {
        var link = links[i];
        if (link)
        {
            var url = link.getAttribute("href");
            if (url == "http://www.baidu.com/shifen/")
            {
                var par = link.parentNode;
                while (par.tagName.toLowerCase() != "table")
                {
                    par = par.parentNode;
                }
                toRemove[toRemove.length] = par;
            }

        }
    }
    for (var i = 0; i < toRemove.length; ++i)
    {
        toRemove[i].parentNode.removeChild(toRemove[i]);
    }

})();
 

你可能感兴趣的:(屏蔽百度广告的脚本)