Skip to content

Instantly share code, notes, and snippets.

@sayak-sarkar
Forked from debloper/9GAG.js
Created July 3, 2014 21:30
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 sayak-sarkar/e509ed4de2fb9fc8cb04 to your computer and use it in GitHub Desktop.
Save sayak-sarkar/e509ed4de2fb9fc8cb04 to your computer and use it in GitHub Desktop.
// Remap $ to jQuery object
var $ = jQuery;
// The real fun begins... first catch all the post-anchors & loop on them
$(".badge-evt.badge-nsfw-entry-cover").each(function () {
// Find out the ID of the post
var id = ($(this).attr("href").split("/"))[4];
// Construct the `quite guessable` image URL
var url = "http://d3dsacqprgcsqh.cloudfront.net/photo/" + id + "_460s.jpg";
// Put in an image element with source as the formed URL
$(this).html("<img src=" + url + " />");
});
// TODO: auto-run after loading new elements on page-scroll, handle GIF vs. JPG, handle post-versions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment