annotate tweetdeck-large-image.user.js @ 46:c20e3e6b0a3f

Even more rulesss
author nanaya <me@nanaya.pro>
date Thu, 24 Aug 2017 20:51:06 +0900
parents 32a213717e6a
children 2e1cae72a63e
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
33
Edho Arief <me@myconan.net>
parents: 28
diff changeset
4 // @version 1.0.2
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
35
32a213717e6a Update update url
nanaya <me@nanaya.pro>
parents: 33
diff changeset
9 // @downloadURL https://bitbucket.org/!api/2.0/snippets/nanayapro/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() {
33
Edho Arief <me@myconan.net>
parents: 28
diff changeset
13 "use strict";
Edho Arief <me@myconan.net>
parents: 28
diff changeset
14
Edho Arief <me@myconan.net>
parents: 28
diff changeset
15 var $ = jQuery
Edho Arief <me@myconan.net>
parents: 28
diff changeset
16 var replaceLink = function(e) {
Edho Arief <me@myconan.net>
parents: 28
diff changeset
17 var link = e.currentTarget
Edho Arief <me@myconan.net>
parents: 28
diff changeset
18 if (link._ecUserscript === true) { return }
25
Edho Arief <me@myconan.net>
parents: 24
diff changeset
19
33
Edho Arief <me@myconan.net>
parents: 28
diff changeset
20 var images = link.getElementsByClassName("media-img")
28
Edho Arief <me@myconan.net>
parents: 26
diff changeset
21
33
Edho Arief <me@myconan.net>
parents: 28
diff changeset
22 var url
28
Edho Arief <me@myconan.net>
parents: 26
diff changeset
23 if (images.length) {
33
Edho Arief <me@myconan.net>
parents: 28
diff changeset
24 url = images[0].src.replace(/:[a-z0-9]+$/, "")
28
Edho Arief <me@myconan.net>
parents: 26
diff changeset
25 } else {
33
Edho Arief <me@myconan.net>
parents: 28
diff changeset
26 url = getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)(:small)?\1\)$/, "$2")
28
Edho Arief <me@myconan.net>
parents: 26
diff changeset
27 }
33
Edho Arief <me@myconan.net>
parents: 28
diff changeset
28 link.setAttribute("href", url + ":orig")
Edho Arief <me@myconan.net>
parents: 28
diff changeset
29 link._ecUserscript = true
Edho Arief <me@myconan.net>
parents: 28
diff changeset
30 }
Edho Arief <me@myconan.net>
parents: 28
diff changeset
31
Edho Arief <me@myconan.net>
parents: 28
diff changeset
32 $(document).off(".ec-userscript")
Edho Arief <me@myconan.net>
parents: 28
diff changeset
33 $(document).on("mouseenter.ec-userscript", ".js-media-image-link", replaceLink)
24
Edho Arief <me@myconan.net>
parents:
diff changeset
34 }).call();