Convert Telegram links to Tgstat links
目前為
// ==UserScript==
// @name Telegram Link to TGStat Converter
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Convert Telegram links to Tgstat links
// @author w4t3r1ily
// @match *://*/*
// @include *
// @grant none
// @icon https://www.google.com/s2/favicons?sz=64&domain=tgstat.com
// ==/UserScript==
(function() {
'use strict';
const originalPath = 'https://t.me/';
const newPath = 'https://tgstat.com/en/channel/@';
document.querySelectorAll('a').forEach(link => {
if (link.href.includes(originalPath)) {
const identifier = link.href.split(originalPath)[1];
const newLink = document.createElement('a');
newLink.href = newPath + identifier;
newLink.innerText = ' ' + newLink.href;
const br = document.createElement('br');
link.parentNode.insertBefore(br, link.nextSibling);
link.parentNode.insertBefore(newLink, br.nextSibling);
}
});
})();