Greasy Fork

Greasy Fork is available in English.

自动跳转以下各类外链跳转页到目的地址

自动跳转以下各类外链跳转页到目的地址,包括 QQ、微信所谓“非官方页面”等

目前为 2022-07-13 提交的版本,查看 最新版本

// ==UserScript==
// @name        自动跳转以下各类外链跳转页到目的地址
// @description 自动跳转以下各类外链跳转页到目的地址,包括 QQ、微信所谓“非官方页面”等
// @author      AnnAngela
// @version     1.1.1
// @mainpage    http://greasyfork.icu/scripts/446839
// @supportURL  http://greasyfork.icu/scripts/446839/feedback
// @match       *://c.pc.qq.com/*
// @match       *://docs.qq.com/scenario/link.html*
// @match       *://afdian.net/link*
// @match       *://weixin110.qq.com/cgi-bin/mmspamsupport-bin/newredirectconfirmcgi*
// @match       *://t.cn/*
// @match       *://www.jianshu.com/go-wild*
// @match       *://link.csdn.net/*
// @match       *://link.zhihu.com/*
// @run-at      document-start
// @license     GNU General Public License v3.0 or later
// @namespace http://greasyfork.icu/users/129402
// ==/UserScript==
"use strict";
const hide = () => {
    try {
        document.documentElement.style.display = "none";
        document.title = "跳转中……";
    } catch { }
};
const searchParams = new URL(location.href).searchParams;
if (location.href.includes("c.pc.qq.com/middle.html") || location.href.includes("c.pc.qq.com/middlem.html") || location.href.includes("c.pc.qq.com/index.html")) {
    hide();
    location.replace(searchParams.get("pfurl"));
}
if (location.href.includes("docs.qq.com/scenario/link.html") || location.href.includes("jianshu.com/go-wild")) {
    hide();
    location.replace(searchParams.get("url"));
}
if (location.href.includes("afdian.net/link") || location.href.includes("link.csdn.net/?target=") || location.href.includes("link.zhihu.com/?target=")) {
    hide();
    location.replace(searchParams.get("target"));
}
if (location.href.includes("weixin110.qq.com/cgi-bin/mmspamsupport-bin/newredirectconfirmcgi")) {
    let flag = false;
    setInterval(() => {
        if (!flag && "url" in (unsafeWindow.cgiData || {})) {
            hide();
            flag = true;
            location.replace(new DOMParser().parseFromString(unsafeWindow.cgiData.url, "text/html").documentElement.textContent);
        }
    }, 100);
}
if (location.href.includes("t.cn/")) {
    let flag = false;
    setInterval(() => {
        const url_view_code = unsafeWindow.document.querySelector(".url_view_code");
        if (!flag && url_view_code) {
            try {
                const url = new URL(url_view_code.innerText);
                hide();
                flag = true;
                location.replace(url);
            } catch { }
        }
    }, 100);
}