4
这个用户还没有留下简介。
当前还没有回复,欢迎成为第一个参与讨论的人。
隔壁偷的代码
t.me 还没修好,很多网站上的链接也没即时更新
安装指南
油猴插件点击 添加新脚本
清空内容并粘贴代码
左上角 文件 保存
enjoy🥳
ts// ==UserScript==
// [@name](/users/name) Telegram 域名替换器 (t.me -> telegram.me)
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 自动将网页中的 t.me 链接替换为 telegram.me
// @author YourName
// @match *://*/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
// 核心替换逻辑
function replaceLinks() {
// 查找所有以 https://t.me/ 或 http://t.me/ 开头的链接
const links = document.querySelectorAll('a[href*="t.me"]');
links.forEach(link => {
if (link.href.includes('://t.me/')) {
link.href = link.href.replace('://t.me/', '://telegram.me/');
// 如果标签文本本身也是网址,同步修改文本显示
if (link.textContent.includes('t.me/')) {
link.textContent = link.textContent.replace('t.me/', 'telegram.me/');
}
}
});
}
// 1. 页面加载时立即执行一次
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', replaceLinks);
} else {
replaceLinks();
}
// 2. 使用 MutationObserver 监听动态加载的网页内容(比如推特、论坛的滚动加载)
const observer = new MutationObserver((mutations) => {
replaceLinks();
});
observer.observe(document.body || document.documentElement, {
childList: true,
subtree: true
});
})();