禁止firefox 重定向脚本

// ==UserScript==
// @name           Google direct Link
// @namespace      http://userscripts.org/users/tommy
// @author         .
// @description    remove google search and image link redirection to speed up your browsing and hide referrer
// @include        *.google.*/*
// @version        0.0.5
// @run-at         document-start
// ==/UserScript==


var hideReferer = true,
    newTab = true,
    showCache = false;

var ua = navigator.userAgent,
    wK = ua.toLowerCase().indexOf('webkit') > -1,
    S = location.protocol === 'https:';

function addEvent(a, b, c) {
    if (a.addEventListener) {
        a.addEventListener(b, c, false);
    }
}

function removeEvent(a, b, c) {
    if (a.removeEventListener) {
        a.removeEventListener(b, c, false);
    }
}

if (Object.defineProperty) {
    Object.defineProperty(window, 'rwt', {
        value: function() {},
        writable: false,
        configurable: false
    })
} else {
    window.__defineGetter__('rwt', function() {
        return function() {}
    })
}

if (showCache) {
    addEvent(window, 'DOMNodeInserted', cache);
}

function cache() {
    var cc = document.querySelectorAll('.vshid');
    if (cc) {
        for (var i = 0; i < cc.length; ++i) {
            cc[i].style.display = 'inline';
        }
    }
}

function proxy(e) {
    if (e && e.localName == 'a' && (e.className == 'l' || e.className == 'rg_l' || e.parentNode.className == 'vshid' || e.parentNode.className == 'gl')) {
        var m = /&imgurl=([^&]+)/.exec(e.href);
        if (m) e.href = m[1];
        if (newTab) e.target = "_blank";
        if (hideReferer) {
            if (wK) {
                e.rel = "noreferrer";
            } else if (!S && e.href.indexOf('http-equiv="refresh"') == -1) {
                e.href = 'data:text/html, <meta http-equiv="refresh" content="0;URL=' + encodeURIComponent(e.href) + '" charset="utf-8">';
            }
        }
    }
}

function doStuff(e) {
    var a = e.target;
    if (a.localName != 'a') {
        for (; a; a = a.parentNode){
            proxy(a);
        }
    } else {
        proxy(a);
    }
}

addEvent(window, "mousedown", doStuff);

转载于:https://www.cnblogs.com/zeroone/archive/2012/10/18/2729117.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值