pseudonymous/better-better-booru

Script inconsistently fails to run

Closed this issue · 6 comments

Sometimes the script just doesn't do anything. It's probably related to Danbooru's JavaScript being changed to asynchronous. It seems to happen when the the browser doesn't load Danbooru's JavaScript from the cache. I think I've already got a workaround using "document.readyState" and a "0ms" timer, but I'll have to put it to more of a test when done at work.

I was able to make the script work consistently by checking typeof(Danbooru) every 100ms (max 2 seconds) and only running bbbScript once typeof(Danbooru) becomes defined. I have essentially no experience with Javascript so this workaround is probably horribly inefficient, but I hope it helps anyway.
bbb-modified.zip

i have the same issue

it says i need a gold account for pay2see images and the script itself isn't appearing at all unless i wait a couple of minutes

Posting again from work. The problem definitely stems from the asynchronous change to Danbooru's JavaScript and I've basically got it pegged so that the script can continue to work like it has been via script managers and as a standalone script/extension. The answer lies in using a load even listener on Danbooru's script and modifying how the script detects whether it needs to embed itself as a standalone script. Assuming my schedule can line up with Pseudonymous' schedule when I'm back home, an update should be available this weekend (hopefully within the next 12 hours).

Actually, until I get home, feel free to test where the script is currently at for yourselves:
https://raw.githubusercontent.com/pseudonymous/better-better-booru/async-fix-test/better-better-booru.user.js

The version number won't change yet, but it is new. Changes can be viewed here:
0d74626

Didn't anticipate having to deal with Danbooru's new timing messing with the event listeners. I think I've combed through them and found the buggy parts. If nothing else turns up, cleaning up should be the only thing left... The previous link is the same link for the script in the progress.

Second revision changes from the first revision:
29f7da5

Officially pushed version 7.2.2 on GitHub so it should eventually make its way to GreasyFork.

GitHub link:
https://github.com/pseudonymous/better-better-booru/raw/master/better-better-booru.user.js

Related changes:
e733ffc
2b448cc