删除链接重定向

点击页面左下角蓝色按钮删除超链接中的第三方跳转,目前支持的网站有知乎、简书、掘金等等网站。如果发现没有删除第三方跳转,或者新的超链接是新生成的,多次点击该按钮即可。作者:浴火凤凰(QQ:307053741,油猴脚本讨论QQ群:194885662)

目前為 2020-01-09 提交的版本,檢視 最新版本

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         删除链接重定向
// @namespace    https://github.com/kingphoenix2000/tampermonkey_scripts
// @supportURL   https://github.com/kingphoenix2000/tampermonkey_scripts
// @version      0.1.1
// @author       浴火凤凰(QQ:307053741,油猴脚本讨论QQ群:194885662)
// @description  点击页面左下角蓝色按钮删除超链接中的第三方跳转,目前支持的网站有知乎、简书、掘金等等网站。如果发现没有删除第三方跳转,或者新的超链接是新生成的,多次点击该按钮即可。作者:浴火凤凰(QQ:307053741,油猴脚本讨论QQ群:194885662)
// @homepage     https://blog.csdn.net/kingwolf_javascript/
// @include      *://*.zhihu.com/*
// @include      *://*.jianshu.com/*
// @include      *://juejin.im/*
// @grant        none
// @note         2020-01-09更新简书的跳转链接数据
// ==/UserScript==

(function () {
    'use strict';

    let removeURLList = [
        "https://link.zhihu.com/?target=",
        "http://link.zhihu.com/?target=",
        "https://link.jianshu.com/?t=",
        "https://links.jianshu.com/go?to=",
        "https://link.juejin.im/?target="
    ];

    let len = removeURLList.length;
    let div = document.createElement("div");
    div.id = "removeLinksRedirection";
    div.innerText = "删除链接重定向";
    div.style.cssText = "width: 150px;font-size:15px;padding: 7px;bottom: 35px;left: 35px;z-index: 1000;background-color: #0077e6;position: fixed;border-radius: 25px;text-align: center;cursor: pointer;color: #fff;";
    div.onclick = function (e) {
        let links = document.links;
        links = Array.from(links);
        links.forEach(function (a) {
            let href = a.href;
            for (let i = 0; i < len; i++) {
                let url = removeURLList[i];
                href = href.replace(url, '');
            }
            if (href.startsWith("http")) {
                href = decodeURIComponent(href);
                a.href = href;
            }
            else {
                console.log("错误的网址: ", a.href);
            }
        });
        this.innerText = "操作成功!";
        setTimeout(function () { document.getElementById("removeLinksRedirection").innerText = "删除链接重定向"; }, 3000);
    }

    document.body.appendChild(div);

})();