comparison 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
comparison
equal deleted inserted replaced
27:2a4e34183b01 28:aa50069d6371
1 // ==UserScript== 1 // ==UserScript==
2 // @name Tweetdeck large image 2 // @name Tweetdeck large image
3 // @namespace https://myconan.net 3 // @namespace https://myconan.net
4 // @version 1.0.0 4 // @version 1.0.1
5 // @description No more stupid link for images in tweetdeck 5 // @description No more stupid link for images in tweetdeck
6 // @author nanaya 6 // @author nanaya
7 // @match https://tweetdeck.twitter.com/* 7 // @match https://tweetdeck.twitter.com/*
8 // @grant none 8 // @grant none
9 // @downloadURL https://bitbucket.org/!api/2.0/snippets/nanaya1/TK64/tip/files/tweetdeck-large-image.user.js 9 // @downloadURL https://bitbucket.org/!api/2.0/snippets/nanaya1/TK64/tip/files/tweetdeck-large-image.user.js
15 $(document).off('.ec-userscript'); 15 $(document).off('.ec-userscript');
16 $(document).on('mouseenter.ec-userscript', '.js-media-image-link', function(e) { 16 $(document).on('mouseenter.ec-userscript', '.js-media-image-link', function(e) {
17 var link = e.currentTarget; 17 var link = e.currentTarget;
18 if (link._ecUserscript === true) { return; } 18 if (link._ecUserscript === true) { return; }
19 19
20 var url = getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)(:small)?\1\)$/, '$2'); 20 var images = link.getElementsByClassName('media-img');
21
22 var url;
23 if (images.length) {
24 url = images[0].src.replace(/:[a-z0-9]+$/, '');
25 } else {
26 url = getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)(:small)?\1\)$/, '$2');
27 }
21 link.setAttribute('href', url + ':orig'); 28 link.setAttribute('href', url + ':orig');
22 link._ecUserscript = true; 29 link._ecUserscript = true;
23 }); 30 });
24 }).call(); 31 }).call();