知乎跳轉鏈接修復

將跳轉鏈接改爲原鏈接。

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name                zhihu link fix
// @name:zh-CN          知乎跳转链接修复
// @name:zh-TW          知乎跳轉鏈接修復
// @namespace           zhihaofans
// @version             0.2
// @description         Change the jump link to the original link.
// @description:zh-CN   将跳转链接改为原链接。
// @description:zh-TW   將跳轉鏈接改爲原鏈接。
// @author              zhihaofans
// @require             https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js
// @match               https://*.zhihu.com/*
// ==/UserScript==

(function () {
    console.log("zhihu link fix:Start");
    $(document).ready(function () {
        var l_n = $("a").length;
        for (var a = 0; a < l_n; a++) {
            if ($("a").eq(a).attr("href").startsWith("https://link.zhihu.com/?target=")) {
                console.log($("a").eq(a).attr("href"));
                console.log($("a").eq(a).attr("href").startsWith("https://link.zhihu.com/?target="));
                var new_link = decodeURIComponent($("a").eq(a).attr("href").replace("https://link.zhihu.com/?target=", ""));
                $("a").eq(a).attr("href", new_link);
                console.log(new_link);
                console.log("======");
            }
        }
        console.log("zhihu link fix:End");
    });
})();