Last active
August 29, 2015 14:21
-
-
Save lgp171188/930121035febce40a312 to your computer and use it in GitHub Desktop.
Auto expand t.co links on Twitter
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 Auto expand t.co links on Twitter | |
// @namespace https://github.com/lgp171188 | |
// @include https://twitter.com/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
function expandTwitterShortlinks() { | |
var twitter_shortlinks = document.getElementsByClassName('twitter-timeline-link'); | |
for (var i = 0; i < twitter_shortlinks.length; i++) { | |
var shortlink = twitter_shortlinks[i]; | |
if (shortlink.classList.contains('tco-url-expanded')) { | |
continue; | |
} | |
else { | |
var actual_url = shortlink.getAttribute('data-expanded-url'); | |
shortlink.setAttribute('href', actual_url); | |
shortlink.classList.add('tco-url-expanded'); | |
} | |
} | |
} | |
document.addEventListener('DOMNodeInserted', expandTwitterShortlinks, false); | |
expandTwitterShortlinks(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment