js that expand all the img link into img(from reddit)

  1: javascript: 
  2: var x= $(".content")
  3: .find("a")
  4: .each(
  5: function()
  6: {
  7: var href=$(this).attr("href");
  8: if((!$(this).hasClass("drowsapMorphed")) 
  9: && ($(this).next(".drowsapMorphed").length==0) 
 10: && href && (href.indexOf('imgur')>=0 
 11: || href.indexOf('jpeg')>=0 
 12: || href.indexOf('jpg')>=0 || href.indexOf('png')>=0))
 13: {
 14: var ext =(href.indexOf('imgur')>=0 
 15: && href.indexOf('jpg')<0 
 16: && href.indexOf('png')<0) 
 17: ? '.jpg' :''; 
 18: var img = $("<a class='drowsapMorphed' href='"+href+"' target='blank' 
 19: style='display:block'>
 20: <img style='display:block;max-width:780px;' src='"+href+ ext+"' /></a>");
 21: $(this).after(img);
 22: }
 23: });

Advertisements
This entry was posted in Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s