Skip to content

Instantly share code, notes, and snippets.

@mazuhl
Created November 2, 2009 12:06
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 mazuhl/224117 to your computer and use it in GitHub Desktop.
Save mazuhl/224117 to your computer and use it in GitHub Desktop.
Javascript to display images in Reddit thread - convert into a single line and paste into the address bar - I didn't write this, but thought I'd save it here!
var x = $(".content").find("a").each(
function(){
var href = $(this).attr("href");
if((!$(this).hasClass("drowsapMorphed")) && ($(this).next(".drowsapMorphed").length==0) && href && (href.indexOf('imgur')>=0 || href.indexOf('jpeg')>=0 || href.indexOf('jpg')>=0 || href.indexOf('png')>=0)){
var ext = (href.indexOf('imgur')>=0 && href.indexOf('jpg')<0 && href.indexOf('png')<0) ? '.jpg' :'';
var img = $("<a class='drowsapMorphed' href='"+href+"' target='blank' style='display:block'><img style='display:block;max-width:780px;' src='"+href+ ext+"' /></a>");
$(this).after(img);
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment