# HG changeset patch # User nanaya # Date 1562725748 -32400 # Node ID a065dafbe010571308a198757eaa870cdc91748a # Parent 753765f3814ec915988985167993e1bfc10685cc Update to handle new tweetdeck?/twitter? url diff -r 753765f3814e -r a065dafbe010 tweetdeck-large-image.user.js --- 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); };