Greasy Fork

Greasy Fork is available in English.

Tencent URL redirect

解决打开 QQ 链接提示“非官方站点”和腾讯文档打开链接提示“即将离开腾讯文档”

当前为 2022-08-16 提交的版本,查看 最新版本

// ==UserScript==
// @name         Tencent URL redirect
// @namespace    http://bkt.moe/
// @version      0.2
// @description  解决打开 QQ 链接提示“非官方站点”和腾讯文档打开链接提示“即将离开腾讯文档”
// @author       ShadowPower
// @match        https://c.pc.qq.com/middlem.html*
// @match        https://docs.qq.com/scenario/link.html*
// @run-at       document-start
// @grant        none
// @license      AGPL
// ==/UserScript==


(function() {
    'use strict';

    stop();
    const queryParams = ['pfurl', 'url'];
    const params = new URLSearchParams(location.search);
    queryParams.forEach(queryParam => {
        if (params.has(queryParam)) {
            const encoded_url = params.get(queryParam);
            let url = decodeURIComponent(encoded_url);
            if (!/^https?:\/\//i.test(url)) {
                url = 'https://' + url;
            }
            location.replace(url);
        }
    });
})();