Skip to content

Instantly share code, notes, and snippets.

@larvata
Last active March 15, 2018 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larvata/6a04963601dbac34433c to your computer and use it in GitHub Desktop.
Save larvata/6a04963601dbac34433c to your computer and use it in GitHub Desktop.
twitter full size image
// ==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