360搜索真實鏈接地址重定向

搜索結果鏈接修正,直接跳轉至目標網址,而不經過中間的二次跳轉頁面

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name                Link Redirect Fix for 360so
// @name:zh-CN          360搜索真实链接地址重定向
// @name:zh-TW          360搜索真實鏈接地址重定向
// @description         Avoid link redirect for 360 search
// @description:zh-CN   搜索结果链接修正,直接跳转至目标网址,而不经过中间的二次跳转页面
// @description:zh-TW   搜索結果鏈接修正,直接跳轉至目標網址,而不經過中間的二次跳轉頁面

// @author              Moshel
// @namespace           https://hzy.pw
// @homepageURL         https://hzy.pw/p/2056
// @supportURL          https://github.com/h2y/link-fix
// @license             GPL-3.0
// @icon                https://p.ssl.qhimg.com/t011a6c04685b5d3b80.png

// @grant               none
// @run-at              document-end
// @include             https://www.so.com/s?*

// @date                06/09/2016
// @modified            08/07/2016
// @version             1.0.1.1
// ==/UserScript==


!function() {

    var dom = null;
    function ajax_fixer() {
        var new_dom = document.querySelector('#m-result');
        if (new_dom && new_dom !== dom) {
            dom = new_dom;
            main();
        }
        setTimeout(ajax_fixer, 2222);
    }
    ajax_fixer();


    function main() {
        var num = 0,
            as = dom.querySelectorAll('a');
        for(var i=0; i<as.length; i++) {
            var old = as[i].href.match(/url=(.+?)(&|$)/);
            if(old && old.length>=2) {
                as[i].href = decodeURIComponent(old[1]);
                num++;
            }
        }
        if(num)
            console.log(num+' 条链接已重定向至真实地址');
    }

}();