annotate tweetdeck-large-image.user.js @ 53:28fde586a234

Add twitter anti-crap (part 1)
author nanaya <me@nanaya.pro>
date Sat, 30 Jun 2018 21:50:51 +0900
parents 2e1cae72a63e
children 19c391840d4a
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
49
2e1cae72a63e Semicolons
nanaya <me@nanaya.pro>
parents: 35
diff changeset
15 var $ = jQuery;
33
Edho Arief <me@myconan.net>
parents: 28
diff changeset
16 var replaceLink = function(e) {
49
2e1cae72a63e Semicolons
nanaya <me@nanaya.pro>
parents: 35
diff changeset
17 var link = e.currentTarget;
2e1cae72a63e Semicolons
nanaya <me@nanaya.pro>
parents: 35
diff changeset
18 if (link._ecUserscript === true) { return; }
25
Edho Arief <me@myconan.net>
parents: 24
diff changeset
19
49
2e1cae72a63e Semicolons
nanaya <me@nanaya.pro>
parents: 35
diff changeset
20 var images = link.getElementsByClassName("media-img");
28
Edho Arief <me@myconan.net>
parents: 26
diff changeset
21
49
2e1cae72a63e Semicolons
nanaya <me@nanaya.pro>
parents: 35
diff changeset
22 var url;
28
Edho Arief <me@myconan.net>
parents: 26
diff changeset
23 if (images.length) {
49
2e1cae72a63e Semicolons
nanaya <me@nanaya.pro>
parents: 35
diff changeset
24 url = images[0].src.replace(/:[a-z0-9]+$/, "");
28
Edho Arief <me@myconan.net>
parents: 26
diff changeset
25 } else {
49
2e1cae72a63e Semicolons
nanaya <me@nanaya.pro>
parents: 35
diff changeset
26 url = getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)(:small)?\1\)$/, "$2");
28
Edho Arief <me@myconan.net>
parents: 26
diff changeset
27 }
49
2e1cae72a63e Semicolons
nanaya <me@nanaya.pro>
parents: 35
diff changeset
28 link.setAttribute("href", url + ":orig");
2e1cae72a63e Semicolons
nanaya <me@nanaya.pro>
parents: 35
diff changeset
29 link._ecUserscript = true;
2e1cae72a63e Semicolons
nanaya <me@nanaya.pro>
parents: 35
diff changeset
30 };
33
Edho Arief <me@myconan.net>
parents: 28
diff changeset
31
49
2e1cae72a63e Semicolons
nanaya <me@nanaya.pro>
parents: 35
diff changeset
32 $(document).off(".ec-userscript");
2e1cae72a63e Semicolons
nanaya <me@nanaya.pro>
parents: 35
diff changeset
33 $(document).on("mouseenter.ec-userscript", ".js-media-image-link", replaceLink);
24
Edho Arief <me@myconan.net>
parents:
diff changeset
34 }).call();