Greasy Fork

PC微信链接自动打开

PC上使用浏览器点开微信链接,在提示非微信官方链接页面自动打开对应的链接

当前为 2023-05-19 提交的版本,查看 最新版本

// ==UserScript==
// @name         PC微信链接自动打开
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  PC上使用浏览器点开微信链接,在提示非微信官方链接页面自动打开对应的链接
// @author       huapeng222
// @match        https://weixin110.qq.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    const wechatTargets = document.getElementsByClassName("weui-msg__desc")
    let isWechatLink = false;
    let linkUrl = ""
    if (wechatTargets && wechatTargets.length > 0) {
        for (let i = 0; i< wechatTargets.length ;i++ ) {
            const e = wechatTargets[i];
            if (e.className === "ui-ellpisis weui-msg__desc") {
                linkUrl = e.textContent;
            }
            if (e.textContent.indexOf("非微信官方网页") >= 0) {
                isWechatLink = true;
                break;
            }
        }
    }
    if (isWechatLink) {
        window.location.href = linkUrl;
    }
})();