Skip to content

Instantly share code, notes, and snippets.

@Dakta
Forked from jsocol/gist:1568904
Created November 18, 2012 06:50
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 Dakta/4103917 to your computer and use it in GitHub Desktop.
Save Dakta/4103917 to your computer and use it in GitHub Desktop.
Bookmarklet to add inline full-size images to Reddit.
javascript: (function () {
var things = document.querySelectorAll("div.thing");
for (var j = 0; j < things.length; j++) {
var thing = things[j],
entry = thing.querySelectorAll("div.entry")[0],
thumb = thing.querySelectorAll("a.thumbnail")[0],
img = new Image;
img.style.display = 'block';
img.style.width = '100%';
if (thumb) {
var href = thumb.href;
if (/\.(png|gif|jpg)$/i.test(href)) img.src = href;
else if (/imgur\.com/i.test(href)) {
var id = /\w+?$/.exec(href)[0];
img.src = "http://i.imgur.com/" + id + ".jpg";
} else if (/picsarus\.com/i.test(href)) {
var id = /\w+?$/.exec(href)[0];
img.src = "http://picsarus.com/" + id + ".jpg";
}
if (img.src) entry.appendChild(img);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment