Mercurial > ec-userscripts
comparison tweetdeck-large-image.user.js @ 63:53d0f935ecb8
Fix orig might be in different format
author | nanaya <me@nanaya.pro> |
---|---|
date | Wed, 10 Jul 2019 22:26:12 +0900 |
parents | a065dafbe010 |
children | 6715e53ad0bf |
comparison
equal
deleted
inserted
replaced
62:a065dafbe010 | 63:53d0f935ecb8 |
---|---|
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 2.0.4 | 4 // @version 2.0.5 |
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/nanayapro/ec-userscripts/raw/tip/tweetdeck-large-image.user.js | 9 // @downloadURL https://bitbucket.org/nanayapro/ec-userscripts/raw/tip/tweetdeck-large-image.user.js |
52 url = getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)\1\)$/, "$2"); | 52 url = getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)\1\)$/, "$2"); |
53 } else { | 53 } else { |
54 url = image.src; | 54 url = image.src; |
55 } | 55 } |
56 | 56 |
57 if (url.match(/\..+:.+/) != null) { | 57 parsedUrl = new URL(url); |
58 | |
59 if (parsedUrl.searchParams.get('name') == null) { | |
58 url = url.replace(/(\..+:).+/, "$1orig"); | 60 url = url.replace(/(\..+:).+/, "$1orig"); |
59 } else if (url.match(/name=/) != null) { | 61 } else { |
60 url = url.replace(/(\?|&)name=.+($|&)/, "$1name=orig$2"); | 62 parsedUrl.searchParams.delete('format'); |
63 parsedUrl.searchParams.set('name', 'orig'); | |
64 url = parsedUrl.href; | |
61 } | 65 } |
62 | 66 |
63 link.setAttribute("href", url); | 67 link.setAttribute("href", url); |
64 | 68 |
65 }; | 69 }; |