Last active
October 27, 2022 13:46
-
-
Save mxamber/045bc1858a1d4bc6fb6b201f31a91d7e to your computer and use it in GitHub Desktop.
Replacing many t.co links with the actual urls on Twitter (no card links yet)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Twitter Link Fix | |
// @version 0.2 | |
// @description No more t.co | |
// @author mxamber | |
// @match https://twitter.com/* | |
// @icon https://www.google.com/s2/favicons?domain=twitter.com | |
// @grant none | |
// ==/UserScript== | |
function fixLinks() { | |
let links = document.querySelectorAll("a[rel='noopener noreferrer nofollow']:not(div[data-testid*='card'] a[rel]):not(div[data-testid*='Card'] a[rel])"); | |
links.forEach(element => { | |
if(!element.href.startsWith("https://t.co")) { return; } | |
let href = element.innerText; | |
if(href[href.length - 1] == "\u2026" || href[href.length - 1] == "…") { | |
href = href.substr(0, href.length - 1); | |
} | |
element.href = href; | |
}); | |
} | |
window.setInterval(fixLinks, 1500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment