Created
October 1, 2018 18:04
-
-
Save tajnymag/5c29a338e4dc72ff17ad2d02eab3da1d to your computer and use it in GitHub Desktop.
Script for viewing 9gag NSFW content without being logged in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is this a userscript as well?