删除链接重定向

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

当前为 2020-01-09 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);

})();