Fuck Wechat or zhihu

自动重定向被微信/知乎拦截的链接

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Fuck Wechat or zhihu
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  自动重定向被微信/知乎拦截的链接
// @author       [email protected]
// @match        *://weixin110.qq.com/*
// @match        *://link.zhihu.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    //setTimeout(redirect, 1000)
    redirect()

    function getUrl(){
        const targetEl2 = document.querySelector(".weui-msg__desc")
        const targetEl = document.querySelector(".weui-msg .weui-msg__text-area .ui-ellpisis-content p");
        const zhihuLinkEl = document.querySelector(".link")
        const targetText = targetEl?.innerText
        const targetText2 = targetEl2?.innerText
        const zhihuTargetText = zhihuLinkEl?.innerText
        const urlReg = /^(http:|https:)/img;
        if(urlReg.test(targetText)) {
            return targetText
        }else if(urlReg.test(targetText2)) {
            return targetText2
        }else if(urlReg.test(zhihuTargetText)){
            return zhihuTargetText
        }
        return null;
    }

    function redirect() {
        const url = getUrl()
        if(url) { window.location.href = url }
    }
})();