Skip to content

Instantly share code, notes, and snippets.

@jdb8
Created February 5, 2021 09:33
Show Gist options
  • Save jdb8/7381adda0c40307981d524be7b616fc9 to your computer and use it in GitHub Desktop.
Save jdb8/7381adda0c40307981d524be7b616fc9 to your computer and use it in GitHub Desktop.
simple userscript to auto-remove t.co links for anchor tags. doesn't (yet) work for link embeds
// ==UserScript==
// @name Remove t.co on hover
// @include https://*.twitter.com/*
// @include https://twitter.com/*
// @include http://*.twitter.com/*
// @include http://twitter.com/*
// ==/UserScript==
(function() {
document.addEventListener('mouseover', (e) => {
const t = e.target;
if (t.tagName !== 'A' || !t.href.startsWith('https://t.co')) {
return;
}
const realUrl = t.innerText.replace('…', '').replace('http://', 'https://');
t.href = realUrl;
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment