From d75a9672cdb914a74f1db81f17aa218e77abd250 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 1 Jun 2023 19:23:52 +0200 Subject: [PATCH] t.co repl --- twitter.user.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 twitter.user.js diff --git a/twitter.user.js b/twitter.user.js new file mode 100644 index 0000000..6017bd6 --- /dev/null +++ b/twitter.user.js @@ -0,0 +1,11 @@ +// ==UserScript== +// @match *://*.twitter.com/* +// @run-at document-start +// ==/UserScript== + +function mkurl(txt){if(!/^http/.test(txt)){txt = "https://"+txt}return txt;} +function repllnks(lnks){for(let lnk of lnks){lnk.href = mkurl(lnk.textContent);lnk.classList.add("unshortreplaced");}} +function getlnks(){return document.querySelectorAll("a[href^='https://t.co']:not(.unshortreplaced)");} +function replrun(){repllnks(getlnks());} +replrun(); +let obs = new MutationObserver(replrun);obs.observe(document, {childList:true, subtree:true});