comparison tweetdeck-large-image.user.js @ 67:f03e2d169a8a

Only delete format if there's extension in filename
author nanaya <me@nanaya.pro>
date Thu, 11 Jul 2019 07:37:18 +0900
parents 444b17e657be
children 521dda0a0b6f
comparison
equal deleted inserted replaced
66:444b17e657be 67:f03e2d169a8a
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.5.1 4 // @version 2.0.6
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
57 var parsedUrl = new URL(url) 57 var parsedUrl = new URL(url)
58 58
59 if (parsedUrl.searchParams.get('name') == null) { 59 if (parsedUrl.searchParams.get('name') == null) {
60 url = url.replace(/(\..+:).+/, '$1orig') 60 url = url.replace(/(\..+:).+/, '$1orig')
61 } else { 61 } else {
62 parsedUrl.searchParams.delete('format') 62 if (parsedUrl.pathname.match(/\.[^.]+$/) !== null) {
63 parsedUrl.searchParams.delete('format')
64 }
63 parsedUrl.searchParams.set('name', 'orig') 65 parsedUrl.searchParams.set('name', 'orig')
64 url = parsedUrl.href 66 url = parsedUrl.href
65 } 67 }
66 68
67 link.setAttribute('href', url) 69 link.setAttribute('href', url)