comparison 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
comparison
equal deleted inserted replaced
32:41953e59d06f 33:28505554a8b9
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.1 4 // @version 1.0.2
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
10 // ==/UserScript== 10 // ==/UserScript==
11 11
12 ;(function() { 12 ;(function() {
13 var $ = jQuery; 13 "use strict";
14
15 var $ = jQuery
16 var replaceLink = function(e) {
17 var link = e.currentTarget
18 if (link._ecUserscript === true) { return }
19
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 }
28 link.setAttribute("href", url + ":orig")
29 link._ecUserscript = true
30 }
14 31
15 $(document).off('.ec-userscript'); 32 $(document).off(".ec-userscript")
16 $(document).on('mouseenter.ec-userscript', '.js-media-image-link', function(e) { 33 $(document).on("mouseenter.ec-userscript", ".js-media-image-link", replaceLink)
17 var link = e.currentTarget;
18 if (link._ecUserscript === true) { return; }
19
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 }
28 link.setAttribute('href', url + ':orig');
29 link._ecUserscript = true;
30 });
31 }).call(); 34 }).call();