scripts/twitter.user.js

12 lines
608 B
JavaScript
Raw Normal View History

2023-06-01 17:23:52 +00:00
// ==UserScript==
// @match *://*.twitter.com/*
// @run-at document-start
// ==/UserScript==
2023-06-01 17:29:56 +00:00
function mkurl(txt){if(!/^http/.test(txt)){txt = "https://"+txt}txt = txt.replace(/…$/, "");return txt;}
2023-06-01 17:43:41 +00:00
function repllnks(lnks){for(let lnk of lnks){if(!lnk.querySelector("div"))lnk.href = mkurl(lnk.textContent);lnk.classList.add("unshortreplaced");}}
2023-06-01 17:23:52 +00:00
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});