Skip to content

Instantly share code, notes, and snippets.

@debloper

debloper/9GAG.js

Last active Jun 30, 2019
Embed
What would you like to do?
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);
@ghost

This comment has been minimized.

Copy link

@ghost 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