diff tweetdeck-large-image.user.js @ 28:aa50069d6371

(none)
author Edho Arief <me@myconan.net>
date Tue, 17 Nov 2015 14:01:36 +0000
parents 6ff29abe127d
children 28505554a8b9
line wrap: on
line diff
--- a/tweetdeck-large-image.user.js	Tue Nov 17 12:24:37 2015 +0000
+++ b/tweetdeck-large-image.user.js	Tue Nov 17 14:01:36 2015 +0000
@@ -1,7 +1,7 @@
 // ==UserScript==
 // @name         Tweetdeck large image
 // @namespace    https://myconan.net
-// @version      1.0.0
+// @version      1.0.1
 // @description  No more stupid link for images in tweetdeck
 // @author       nanaya
 // @match        https://tweetdeck.twitter.com/*
@@ -17,7 +17,14 @@
     var link = e.currentTarget;
     if (link._ecUserscript === true) { return; }
     
-    var url = getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)(:small)?\1\)$/, '$2');
+    var images = link.getElementsByClassName('media-img');
+    
+    var url;
+    if (images.length) {
+      url = images[0].src.replace(/:[a-z0-9]+$/, '');
+    } else {
+      url = getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)(:small)?\1\)$/, '$2');
+    }
     link.setAttribute('href', url + ':orig');
     link._ecUserscript = true;
   });