diff tweetdeck-large-image.user.js @ 33:28505554a8b9

(none)
author Edho Arief <me@myconan.net>
date Sun, 25 Dec 2016 07:41:17 +0000
parents aa50069d6371
children 32a213717e6a
line wrap: on
line diff
--- a/tweetdeck-large-image.user.js	Sat Dec 24 04:41:13 2016 +0000
+++ b/tweetdeck-large-image.user.js	Sun Dec 25 07:41:17 2016 +0000
@@ -1,7 +1,7 @@
 // ==UserScript==
 // @name         Tweetdeck large image
 // @namespace    https://myconan.net
-// @version      1.0.1
+// @version      1.0.2
 // @description  No more stupid link for images in tweetdeck
 // @author       nanaya
 // @match        https://tweetdeck.twitter.com/*
@@ -10,22 +10,25 @@
 // ==/UserScript==
 
 ;(function() {
-  var $ = jQuery;
-  
-  $(document).off('.ec-userscript');
-  $(document).on('mouseenter.ec-userscript', '.js-media-image-link', function(e) {
-    var link = e.currentTarget;
-    if (link._ecUserscript === true) { return; }
+  "use strict";
+
+  var $ = jQuery
+  var replaceLink = function(e) {
+    var link = e.currentTarget
+    if (link._ecUserscript === true) { return }
     
-    var images = link.getElementsByClassName('media-img');
+    var images = link.getElementsByClassName("media-img")
     
-    var url;
+    var url
     if (images.length) {
-      url = images[0].src.replace(/:[a-z0-9]+$/, '');
+      url = images[0].src.replace(/:[a-z0-9]+$/, "")
     } else {
-      url = getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)(:small)?\1\)$/, '$2');
+      url = getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)(:small)?\1\)$/, "$2")
     }
-    link.setAttribute('href', url + ':orig');
-    link._ecUserscript = true;
-  });
+    link.setAttribute("href", url + ":orig")
+    link._ecUserscript = true
+  }
+  
+  $(document).off(".ec-userscript")
+  $(document).on("mouseenter.ec-userscript", ".js-media-image-link", replaceLink)
 }).call();
\ No newline at end of file