外链跳转去除确认

打开第三方外链时跳过确认页面,仅支持部分网站

// ==UserScript==
// @name         外链跳转去除确认
// @description  打开第三方外链时跳过确认页面,仅支持部分网站
// @namespace    https://greasyfork.org/zh-CN/users/948411
// @version      1.1
// @author       Moe
// @license      MIT
// @match        https://c.pc.qq.com/middlect.html?*
// @match        https://c.pc.qq.com/ios.html?*
// @match        https://docs.qq.com/scenario/link.html?*
// @match        https://cloud.tencent.com/developer/tools/blog-entry?*
// @match        https://link.zhihu.com/?*
// @match        https://link.csdn.net/?*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    const dict = {
       "https://c.pc.qq.com/middlect.html": "pfurl",                     // QQ 电脑端
       "https://c.pc.qq.com/ios.html": "url",                            // QQ 移动端
       "https://docs.qq.com/scenario/link.html": "url",                  // 腾讯文档
       "https://cloud.tencent.com/developer/tools/blog-entry": "target", // 腾讯云
       "https://link.zhihu.com/": "target",                              // 知乎
       "https://link.csdn.net/": "target",                               // CSDN
    };

    const url = new URL(window.location.href);
    const mainUrl = url.origin + url.pathname;

    if (mainUrl in dict) {
        const params = new URLSearchParams(url.search);
        const targetUrl = new URL(decodeURIComponent(params.get(dict[mainUrl])));
        window.location.replace(targetUrl);
    }
})();