您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Remove legacy=1 parameter from specific Telegram links
当前为
- // ==UserScript==
- // @name Remove Legacy Parameter from Telegram Links
- // @namespace http://tampermonkey.net/
- // @version 1.0
- // @description Remove legacy=1 parameter from specific Telegram links
- // @author ironbox
- // @match https://t.me/*
- // @grant none
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- // Function to remove legacy=1 from a URL
- function removeLegacyParameter(url) {
- let urlObj = new URL(url);
- urlObj.searchParams.delete('legacy');
- return urlObj.toString();
- }
- // Function to update all links on the page
- function updateLinks() {
- // Get all links on the page
- let links = document.querySelectorAll('a');
- // Remove legacy=1 from each link
- links.forEach(link => {
- if (link.href.includes('legacy=1')) {
- link.href = removeLegacyParameter(link.href);
- }
- });
- }
- // Run updateLinks when the page is loaded
- window.addEventListener('load', updateLinks);
- // Run updateLinks every second to handle dynamic content
- setInterval(updateLinks, 1000);
- })();