Topic: Images not loading? Got Greasemonkey or other userscripts loader? Fixed!

Posted under e621 Tools and Applications

Please:
DO read the comments.
DO NOT gripe if it doesn't work, or has side effects.
DO give feedback or patches if it does. ;)

// ==UserScript==
// @name        e621 - Always show posts
// @namespace   https://e621.net
// @description Fixes the bug with display:none in head section.  Beware:  Might disable blacklist - need to test!
// Entire site, so it fixes both the search results and post pages.  Could probably narrow it but seems to work fine.  See also:  Match keyword in GM/TM documentation.
// @include     https://e621.net/*
// @version     1
// @grant       none
// ==/UserScript==

// <style id="blacklisted-hider">
//    .post-preview, #image-container, #c-comments .post, .mod-queue-preview.post-preview, .post-thumbnail {visibility: hidden !important;}
//  </style>
//  onload="GetElementByID("blacklisted-hider").dom.style.display = 'inline';"
// Included examples of stuff that didn't work, so next person learning this knows what not to try:
// blacklisttext = ".post-preview, #image-container, #c-comments .post, .mod-queue-preview.post-preview, .post-thumbnail {visibility: inline !important;}";
// GetElementByID("blacklisted-hider").style.visibility = 'inline !important;';
// GetElementByID("blacklisted-hider").InnerHTML = '';
// GetElementByID(".post-thumbnail").InnerHTML = '';
// GetElementByID(".post-thumbnail").style.visibility = 'inline !important;';
// Different approach:  Change JS file?  Nevermind, it's apparently in the HTML source.  Could have sworn it was added later...
// Explanation:  Selects entire document, then find Div blacklisted-hider, then selects the HTML inside it, and finally replaces it with my patched code.
document.getElementById("blacklisted-hider").innerHTML = ".post-preview, #image-container, #c-comments .post, .mod-queue-preview.post-preview, .post-thumbnail {visibility: visible !important;}"

Enjoy!

Basically, turns out the HTML source for /posts has a style in the head section that hides everything by default, even though it's still loading all the thumbs (I tested - it had 250 requests in Network tab of DOM Inspector). It then goes through and makes them visible individually, and gives warning about 'those' tags if not logged in. It's a strange way to do it, but I guess they had someone with JS turned off complaining. Noticeable is that disabling CSS in uMatrix doesn't disable the style, because it's inline'd into the HTML source directly, instead of loaded through a CSS file. I couldn't get custom CSS in account settings to do this, probably because of the '!important' flag? Oh, well...

A side-effect of doing the blacklist that way, instead of just enabling posts server-side, is that it caused the known bug of a given page having no/less results. Say, you had 250 results with first 50 blacklisted, and 75 results per page, then you'd get 25 results on the first page, then 75 for the others until last page, which only had 25 left, anyways.

At least I didn't have to mess with something like Luscious.net's code. That one builds the entire page using some hackish compiler-based solution. Heh, it literally compiles the code to view the page. I assume because of obfuscation purposes.

If someone has a way to do this on mobile browsers or game consoles or the like, I'm sure there's people that would appreciate it.

Updated

  • 1