scripts/twitter.user.js

12 lines
579 B
JavaScript

// ==UserScript==
// @match *://*.twitter.com/*
// @run-at document-start
// ==/UserScript==
function mkurl(txt){if(!/^http/.test(txt)){txt = "https://"+txt}txt = txt.replace(/…$/, "");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});