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.