Mercurial > ec-userscripts
changeset 62:a065dafbe010
Update to handle new tweetdeck?/twitter? url
author | nanaya <me@nanaya.pro> |
---|---|
date | Wed, 10 Jul 2019 11:29:08 +0900 |
parents | 753765f3814e |
children | 53d0f935ecb8 |
files | tweetdeck-large-image.user.js |
diffstat | 1 files changed, 10 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/tweetdeck-large-image.user.js Sun May 12 01:30:44 2019 +0900 +++ b/tweetdeck-large-image.user.js Wed Jul 10 11:29:08 2019 +0900 @@ -1,7 +1,7 @@ // ==UserScript== // @name Tweetdeck large image // @namespace https://myconan.net -// @version 2.0.3 +// @version 2.0.4 // @description No more stupid link for images in tweetdeck // @author nanaya // @match https://tweetdeck.twitter.com/* @@ -49,19 +49,18 @@ // sometimes the image is just background image of the link. // strip all query strings and original :size suffix if (image == null) { - - var linkStyle = getComputedStyle(link); - - if (linkStyle == null) { - return; - } - - url = linkStyle.backgroundImage.replace(/^url\(('|")?(.+?)(?::small)?(?:\?.*)?\1\)$/, "$2"); + url = getComputedStyle(link).backgroundImage.replace(/^url\(('|")?(.+?)\1\)$/, "$2"); } else { - url = image.src.replace(/:[a-z0-9]+(?:\?.*)?$/, ""); + url = image.src; } - link.setAttribute("href", url + ":orig"); + if (url.match(/\..+:.+/) != null) { + url = url.replace(/(\..+:).+/, "$1orig"); + } else if (url.match(/name=/) != null) { + url = url.replace(/(\?|&)name=.+($|&)/, "$1name=orig$2"); + } + + link.setAttribute("href", url); };