Skip to content

Instantly share code, notes, and snippets.

@tajnymag
Created October 1, 2018 18:04
Show Gist options
  • Save tajnymag/5c29a338e4dc72ff17ad2d02eab3da1d to your computer and use it in GitHub Desktop.
Save tajnymag/5c29a338e4dc72ff17ad2d02eab3da1d to your computer and use it in GitHub Desktop.
Script for viewing 9gag NSFW content without being logged in
function getURLFromID(id) {
return 'https://img-9gag-fun.9cache.com/photo/' + id + '_700b.jpg';
}
function newImageEl(url, attrs) {
const newEl = document.createElement('img');
newEl.src = url;
return newEl;
}
function unhideNaughtyPosts() {
const postEls = document.querySelectorAll('article');
postEls.forEach(el => {
const id = el.id.split('-')[2];
const contentEl = el.querySelector('.nsfw-post');
contentEl.innerHTML = '';
contentEl.appendChild(newImageEl(getURLFromID(id)));
contentEl.classList.toggle('nsfw-post');
});
}
document.querySelector('#container').addEventListener('DOMNodeInserted', e => {
unhideNaughtyPosts()
});
unhideNaughtyPosts()
@neoOpus
Copy link

neoOpus commented Oct 20, 2020

is this a userscript as well?

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