Skip to content

Instantly share code, notes, and snippets.

@debloper
Last active November 15, 2021 07:35
Show Gist options
  • Save debloper/a5a7999ddbc594a882a4 to your computer and use it in GitHub Desktop.
Save debloper/a5a7999ddbc594a882a4 to your computer and use it in GitHub Desktop.
Unlock NSFW without logging in
// Remap $ to jQuery object
var $ = jQuery;
// The real fun begins... first catch all the post-anchors & loop on them
$(document).on("scroll", function () {
// Let's declare some reusable globals for the next iterations
var urlBase = "http://img-9gag-lol.9cache.com/photo/";
$(".badge-evt.badge-nsfw-entry-cover").each(function () {
// Remove the NSFW class, to avoid redundant processing
$(this).removeClass("badge-nsfw-entry-cover");
// Find out the ID of the post
var id = $(this).parent().parent().data("entryId");
// Hence the best-guess image URL is:
var imgUrl = urlBase + id + "_460s.jpg";
// Time to inject an image element with source as the formed URL
$(this).html("<img src=" + imgUrl + " />");
// On click, open the image as GIF in a new tab
// Do so blindly, as there's no definitive way to be sure
$(this).attr("href", imgUrl.split("460s").join("460sa").split(".jpg")[0] + ".gif");
$(this).attr("target", "_blank");
});
});
// TODO: find a way to handle image versions
// Read the video ID:
var query = location.search // Read query param(s)
, vid = query.split("v=")[1] // Get the video ID
, id = query.split("&")[0]; // If multiple query params are present, chuck them
// Whip the browser to haul its ass over to this location
location.assign("http://youtube.com/v/" + id);
Copy link

ghost commented Jan 8, 2018

howto use this JS file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment