annotate tweetdeck-large-image.user.js @ 30:d884de13423b

(none)
author Edho Arief <me@myconan.net>
date Fri, 20 May 2016 18:06:04 +0000
parents aa50069d6371
children 28505554a8b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
Edho Arief <me@myconan.net>
parents:
diff changeset
1 // ==UserScript==
Edho Arief <me@myconan.net>
parents:
diff changeset
2 // @name Tweetdeck large image
Edho Arief <me@myconan.net>
parents:
diff changeset
3 // @namespace https://myconan.net
28
Edho Arief <me@myconan.net>
parents: 26
diff changeset
4 // @version 1.0.1
24
Edho Arief <me@myconan.net>
parents:
diff changeset
5 // @description No more stupid link for images in tweetdeck
Edho Arief <me@myconan.net>
parents:
diff changeset
6 // @author nanaya
Edho Arief <me@myconan.net>
parents:
diff changeset
7 // @match https://tweetdeck.twitter.com/*
Edho Arief <me@myconan.net>
parents:
diff changeset
8 // @grant none
26
Edho Arief <me@myconan.net>
parents: 25
diff changeset
9 // @downloadURL https://bitbucket.org/!api/2.0/snippets/nanaya1/TK64/tip/files/tweetdeck-large-image.user.js
24
Edho Arief <me@myconan.net>
parents:
diff changeset
10 // ==/UserScript==
Edho Arief <me@myconan.net>
parents:
diff changeset
11
Edho Arief <me@myconan.net>
parents:
diff changeset
12 ;(function() {
Edho Arief <me@myconan.net>
parents:
diff changeset
13 var $ = jQuery;
Edho Arief <me@myconan.net>
parents:
diff changeset
14
Edho Arief <me@myconan.net>
parents:
diff changeset
15 $(document).off('.ec-userscript');
25
Edho Arief <me@myconan.net>
parents: 24
diff changeset
16 $(document).on('mouseenter.ec-userscript', '.js-media-image-link', function(e) {
Edho Arief <me@myconan.net>
parents: 24
diff changeset
17 var link = e.currentTarget;
Edho Arief <me@myconan.net>
parents: 24
diff changeset
18 if (link._ecUserscript === true) { return; }
Edho Arief <me@myconan.net>
parents: 24
diff changeset
19
28
Edho Arief <me@myconan.net>
parents: 26
diff changeset
20 var images = link.getElementsByClassName('media-img');
Edho Arief <me@myconan.net>
parents: 26
diff changeset
21
Edho Arief <me@myconan.net>
parents: 26
diff changeset
22 var url;
Edho Arief <me@myconan.net>
parents: 26
diff changeset
23 if (images.length) {
Edho Arief <me@myconan.net>
parents: 26
diff changeset
24 url = images[0].src.replace(/:[a-z0-9]+$/, '');
Edho Arief <me@myconan.net>
parents: 26
diff changeset
25 } else {
Edho Arief <me@myconan.net>
parents: 26
diff changeset
26 url = getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)(:small)?\1\)$/, '$2');
Edho Arief <me@myconan.net>
parents: 26
diff changeset
27 }
25
Edho Arief <me@myconan.net>
parents: 24
diff changeset
28 link.setAttribute('href', url + ':orig');
Edho Arief <me@myconan.net>
parents: 24
diff changeset
29 link._ecUserscript = true;
24
Edho Arief <me@myconan.net>
parents:
diff changeset
30 });
Edho Arief <me@myconan.net>
parents:
diff changeset
31 }).call();