Skip to content

Instantly share code, notes, and snippets.

@kmxz
Created October 11, 2013 17:04
Show Gist options
  • Save kmxz/6938381 to your computer and use it in GitHub Desktop.
Save kmxz/6938381 to your computer and use it in GitHub Desktop.
Show full size imgs for postimg.org instead of thumbs
// ==UserScript==
//
//Displayable Name of your script
// @name Postimg handler
// @include *extreme-board.com/*
//
// ==/UserScript==
function get_further(rt) {
var mt = /<img[^<>]*src='([^<>']+)'[^<>]*\/>/;
var ra = rt.match(mt);
return ra[1];
}
function get_full(sh, cbk) {
var mth = /postimg\.org\/([a-z0-9]+)\//;
var th = sh.match(mth);
if (!th || th.length < 2) { return; }
th = th[1];
var url = 'http://postimg.org/image/' + th + '/';
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200){
cbk(get_further(xhr.responseText));
}
};
xhr.open('get', url, true);
xhr.send(null);
}
var all_imgs = document.getElementsByTagName('img');
for(var i = 0; i < all_imgs.length; i++) {
(function(imgo) {
get_full(imgo.src, function(x) { imgo.src = x; });
})(all_imgs[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment