Forked from lgp171188/auto-expand-tco-links-on-tweetdeck-website.user.js
Last active
June 22, 2016 08:45
Revisions
-
darrik revised this gist
Oct 11, 2015 . 1 changed file with 55 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ // ==UserScript== // @name Auto expand t.co links on Tweetdeck website // @namespace https://github.com/lgp171188 // @include https://tweetdeck.twitter.com/* // @version 2 // @grant none // ==/UserScript== function expandTwitterShortlinks() { @@ -19,5 +19,56 @@ function expandTwitterShortlinks() { } } } function expandTwitterShortimagelinks() { var twitter_shortlinks = document.getElementsByClassName('js-media-image-link'), i, shortlink, actual_url, tmp; for(i = 0; i < twitter_shortlinks.length; i++) { shortlink = twitter_shortlinks[i]; if(shortlink.classList.contains('tco-url-expanded')) { continue; } actual_url = shortlink.getAttribute('style'); if(actual_url !== null) { tmp = actual_url.match(/background-image:url\((.+?)\)/); if(tmp !== null) { shortlink.setAttribute('href', tmp[1]); shortlink.classList.add('tco-url-expanded'); } } } } function expandTwitterShortimagelinksInMediaEmbeds() { var divs = document.getElementsByClassName('med-tray'), tco = new RegExp('https?://t.co/[^"]+', 'g'), i, medtray, full_link, ih; for(i = 0; i < divs.length; i++) { medtray = divs[i]; if(medtray.classList.contains('tco-url-expanded')) { continue; } ih = medtray.innerHTML; full_link = ih.match(/img class=\"media-img\" src=\"([^\"]+)\"/); if(full_link !== null && full_link.length > 0) { medtray.classList.add('tco-url-expanded'); medtray.innerHTML = ih.replace(tco, full_link[1]); } } } function allOfThem() { expandTwitterShortlinks(); expandTwitterShortimagelinks(); expandTwitterShortimagelinksInMediaEmbeds(); } setInterval(allOfThem, 2000); -
lgp171188 created this gist
Oct 6, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ // ==UserScript== // @name Auto expand t.co links on Tweetdeck website // @namespace https://github.com/lgp171188 // @include https://tweetdeck.twitter.com/* // @version 1 // @grant none // ==/UserScript== function expandTwitterShortlinks() { var twitter_shortlinks = document.getElementsByClassName('url-ext'); 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-full-url'); shortlink.setAttribute('href', actual_url); shortlink.classList.add('tco-url-expanded'); } } } document.addEventListener('DOMNodeInserted', expandTwitterShortlinks, false); expandTwitterShortlinks();