Forums / Discussion / General

235,448 total conversations in 7,818 threads

+ New Thread


Sticky Sticky Featured Featured
You Can Now Remove NSFW/Spoiler Covers from Image Galleries

Last posted Jul 07, 2024 at 07:56PM EDT. Added Jan 18, 2017 at 07:20PM EST
49 posts from 26 users

I wrote a script that replaces the NSFW and spoiler cover images with the images they're meant to hide, then shifts the rest of the images around to make room if needed. It looks like this.

If you have a user script extension on your browser, like Tampermonkey on Chrome or Greasemonkey on Firefox, you can download the script here.
https://hastebin.com/ogidemiqic.js

There are definitely some issues with it. On Chrome, for example, the script doesn't kick in on image galleries until I scroll. It will break for sure on galleries with fewer than 4 images. It's heavily reliant on the way KYM is set up right now, so changes to the way gallery pages work are likely to break it.

If you come across any huge issues or can't get the script to work at all, let me know. Finally, keep in mind that the script causes your browser to request one extra HTML page from knowyourmeme.com every time you come across an NSFW or spoiler image in a gallery, so add about 70 KB of data used for each such image if you're counting that sort of thing.

MOD EDIT: If you use this on pages with a lot of spoiler or NSFW images, you can get auto-banned for having a lot of requests to the site. It's up to you to be responsible with this, should you use it. If you do get auto-banned, you can send an email to bans@knowyourmeme.com to have it undone.

Update 1/26/17: The script should no longer cause any autobans. Still refer to bans@knowyourmeme.com if anything occurs.

Last edited Jan 28, 2017 at 10:18AM EST

Maybe now people will stop asking for that feature.

haha no they won't

Anyways, this is really neat and useful. The design (the little red, blue, and purple squares) is pretty smart. It workers perfectly when I try it (Firefox).

robepriority wrote:

So does it crop the images so that your not entirely spoiled?

If not, the squares seem just for moderation/ flagging.

No. If you want to disable the uncovering of spoilers, you can remove || flags.spoiler from line 89. That's all you need.

Good job, this is why PC is better than consoles! j/k
As for Chrome, it isn't even a real browser, so who cares about it.

But couldn't this functionality be included in KYM itself, in user options or such?

Jankovic wrote:

Good job, this is why PC is better than consoles! j/k
As for Chrome, it isn't even a real browser, so who cares about it.

But couldn't this functionality be included in KYM itself, in user options or such?

The coder explained that one once: The way KYM is coded, making such a feature user-related would require a different cache of all images for each user; we just don't have that server space.

Although I don't know about making it a general site feature. But if OP managed to do this, we could look into it maybe but don't quote me on that.

Right, I was afraid of this, but somebody already got banned for using it. I had a feeling that IP bans were based on the number of requests to knowyourmeme.com. I tried to get around that, but I couldn't find any way to determine the URL of an image that's covered up without loading its photo page and pulling it from there. So when Arcanine looked at the body inflation gallery, it saw the requests to individual photo pages and banned him. I didn't try testing the script on a gallery with that many NSFW images, so I didn't notice it on my own.

Last edited Jan 19, 2017 at 12:05PM EST

ArchaicEX wrote:

Right, I was afraid of this, but somebody already got banned for using it. I had a feeling that IP bans were based on the number of requests to knowyourmeme.com. I tried to get around that, but I couldn't find any way to determine the URL of an image that's covered up without loading its photo page and pulling it from there. So when Arcanine looked at the body inflation gallery, it saw the requests to individual photo pages and banned him. I didn't try testing the script on a gallery with that many NSFW images, so I didn't notice it on my own.

I had a theory that the script could get you banned by using it so I tested that and I found out single handedly that using it can get you banned.

It turns out that using it results in an automatic ban when used in predominantly NSFW galleries such as Cat Keyhole Lingerie and Body Inflation where most, if not all images are marked NSFW. Then again, the same can happen in almost any gallery with a sizeable number of NSFW and spoilers due to too many requests in a short amount of time.

TL;DR: using it means you risk getting banned so be careful if you do want to use it.


In case you do get banned, send an email to bans@knowyourmeme.com and James will undo it for you.

Last edited Jan 19, 2017 at 12:39PM EST

ArchaicEX wrote:

No. If you want to disable the uncovering of spoilers, you can remove || flags.spoiler from line 89. That's all you need.

I talked to Archaic about this a little – you can also just remove flags.nsfw | | to only un-hide spoilers.

Note that doing either of these would, in most cases, reduce the number of requests you send to the site, thus making it less likely you'll get auto-banned, should you decide to use it.

I added these to the img elements in galleries that are nsfw or spoiler or both:

classes: img-nsfw and img-spoiler
data attributes: data-original-image-url and data-original-height

The original image urls go to the cdn so requests don't matter.

Nice, thanks. I had a mod update the link in the first post to a new one that doesn't make any requests to knowyourmeme.com any more, and it doesn't need to wait for images to load before adjusting their positions. Sadly, the new classes don't help much, because I still have to go through and inspect every image so that I can move them around.

Odd, that's not in the documentation. How do you know it exists? I got it to work just by using the layoutComplete event and calling layout() an extra time to make sure my handler gets called. A "photos loaded" event would be nice, although it wouldn't make too much of a difference since KYM only seems to adjust the layout when new photos are loaded anyway.

Got an odd thing here, it doesn't work on normal galleries for me, but it still works on the pictures in the trending images at the bottom of the page.

I feel like I'm doing something wrong, but I don't know what it is.

Palemoon browser (yeah I know, it's largely incompatible with lots of things).

And for an example of the bizzare problem, normal entry galleries like
https://knowyourmeme.com/memes/dat-ass/photos
have the script functioning in addition to the trending images.

However, on the actual photo page itself, e.g.
https://knowyourmeme.com/photos/1224605-miss-kobayashis-dragon-maid
The photos under the "You Might Also Like:" section are spoilered.

Furthermore, if I search for a term or click on a tag to search for tagged photos, e.g.
https://knowyourmeme.com/search?context=images&q=tags%3A%28%22quetzalcoatl%22%29
Then the images in the gallery for the tag are spoilered for some reason.

Hope this helps you troubleshoot this.

Pale Moon works fine for me on gallery pages and search pages. The "You Might Also Like" images don't work and won't work. I'd consider adding it now, but they don't have the fancy new attributes James added and I'd like to keep the script 100% safe from IP bans. The "Trending Images" section that appears on single image pages should work, though. Not sure why search pages don't work for you. I tried removing a condition that I think is suspect. It didn't break the script on my copy of Pale Moon, so maybe it'll fix it for you.

https://hastebin.com/qebiyuyepi.js

Thank you for the update, but it didn't work for me.

Here's how my troubleshooting process (the new script you posted will refered to as MkII)

1) Tested MkII with search page
https://knowyourmeme.com/search?context=images&q=tags%3A%28%22quetzalcoatl%22%29
Failure
2) Disabled MkII script and tested with original script on same search page, still failure
3) Disabled Original script and tested with only MkII script on same search page, still failure
4) Tested only the MkII script on gallery
https://knowyourmeme.com/memes/dat-ass/photos
Bizzarely, failure, the previously uncovered nsfw photos were recovered for some reason.
5) Re-tested original script on same gallery, worked as it did before.

Hope this helps.

Last edited Feb 25, 2017 at 11:12PM EST

The pattern I can imagine here is that the gallery bricks don't load for you until the script runs. In the first version you tried, if the bricks aren't loaded when the script runs, it won't set up the replacement. In the second script you tried, it'll try to set up the replacement and fail. Thing is, I have no idea how that could happen. Even with JavaScript off, here's what I see.

Is there some way you can show me what this looks like for you?

Jankovic wrote:

Good job, this is why PC is better than consoles! j/k
As for Chrome, it isn't even a real browser, so who cares about it.

But couldn't this functionality be included in KYM itself, in user options or such?

ArchaicEX wrote:

The pattern I can imagine here is that the gallery bricks don't load for you until the script runs. In the first version you tried, if the bricks aren't loaded when the script runs, it won't set up the replacement. In the second script you tried, it'll try to set up the replacement and fail. Thing is, I have no idea how that could happen. Even with JavaScript off, here's what I see.

Is there some way you can show me what this looks like for you?

Hey there, sorry for going MIA all of a sudden.

What exactly do you mean by what you said? If your questioning whether or not I have the script running, then yes I do have the script running, its always running thanks to Greasemonkey.

And my view looks nothing like your screen cap, its just the same standard stuff as its always been before the script.

I made a small script that do that, if anyone cares.
It make a red border around the NFSW images so you can spot them.

function reveal() { var x = document.getElementsByClassName("img-nsfw"); for(var i in x){ x[i].src = x[i].getAttribute("data-original-image-url"); x[i].style.border = "1px solid #ff0000"; } } window.setInterval(function(){ reveal() }, 500);

Last edited Mar 23, 2017 at 01:18PM EDT

@ArchaicEX
Should that last link you provided last month work atm?
I just found out about this and tried it for the first time, but although greasemonkey says the script is active for a gallery page, nothing at all is changed.
I'm on Firefox 55.0.3 in case you'd want to know.

RandomMan wrote:

The coder explained that one once: The way KYM is coded, making such a feature user-related would require a different cache of all images for each user; we just don't have that server space.

Although I don't know about making it a general site feature. But if OP managed to do this, we could look into it maybe but don't quote me on that.

I Thought It Was Because The Web Designer Guy (No I Do Not Remember) Had To Put In Too Much Effort To Make It Work.

I Might Have Got Some Wires Crossed Though.

Greasemonkey seems to have some added security since I first wrote the script, samgreef. It won't let me access the code in KYM that drives the galleries. Tampermonkey lets me do it, and it has a Firefox version. I could rewrite the script to get around this limitation, but it would mean turning the entire thing into a series of window.eval, which sounds dreadful.

Loath as I am to resurrect this thread, I recently had to refresh firefox and this script doesnt work anymore, anyone know any alternatives?

Greyblades wrote:

Loath as I am to resurrect this thread, I recently had to refresh firefox and this script doesnt work anymore, anyone know any alternatives?

I literally just installed this today and it works fine. The only change I had to make was the http → https edit in the beginning. Install Tampermonkey (not Greasemonkey), copy the contents of the script and paste it into a blank new script in Tampermonkey, edit the beginning where it says http://knowyourmeme.com to say https://knowyourmeme.com, save it and you're done. I'll even paste my copy to GreasyFork/GitHub if you're really having trouble editing it for whatever reason.

EDIT: Here's the link to my edited repost of the script for anyone who can't figure it out:
https://greasyfork.org/en/scripts/396522-uncover-nsfw-knowyourmeme-images
Just install Tampermonkey and then the script and it should function normally. It seems to work fine for me.

Last edited Feb 16, 2020 at 10:11AM EST

Hauu! You must login or signup first!