禁止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);

你可能感兴趣的:(firefox)