Last active
March 15, 2018 07:27
-
-
Save larvata/6a04963601dbac34433c to your computer and use it in GitHub Desktop.
twitter full size image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name twitter full size image | |
// @namespace https://github.com/larvata | |
// @version 0.3 | |
// @description always get the hi-res image from twitter | |
// @author Larvata | |
// @match https://pbs.twimg.com/* | |
// @grant none | |
// @license MIT | |
// ==/UserScript== | |
const { pathname } = window.location; | |
let ignore = true; | |
let nextpath = ''; | |
// test for tweet image | |
if (pathname.startsWith('/media')) { | |
ignore = pathname.endsWith(':orig'); | |
nextpath = `${pathname}:orig`; | |
} | |
else if (pathname.startsWith('/profile_images')) { | |
ignore = !pathname.match(/_\d+x\d+\.\S+$/); | |
nextpath = pathname.replace(/(profile_images)\/(\S+)\/(\S+)_(\S+)\./, (a,b,c,d,e,f)=> { | |
// console.log(a,b,c,d,e,f); | |
return [b,c,d].join('/') + '.'; | |
}); | |
} | |
else { | |
return; | |
} | |
if (ignore) { | |
return; | |
} | |
window.location.pathname = nextpath; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment