pseudonymous / better-better-booru

Various tweaks to make Danbooru better.
110 stars 41 forks source link

Script inconsistently fails to run #59

Closed ghost closed 8 years ago

ghost commented 8 years ago

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.

Nil8r93 commented 8 years ago

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

ghost commented 8 years ago

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

ghost commented 8 years ago

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).

ghost commented 8 years ago

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: https://github.com/pseudonymous/better-better-booru/commit/0d74626b628a29622dd99ff780a53ec22d87864b

ghost commented 8 years ago

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: https://github.com/pseudonymous/better-better-booru/commit/29f7da53e21ce6cc11c92e670b334159b88a1b8b

ghost commented 8 years ago

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: https://github.com/pseudonymous/better-better-booru/commit/e733ffc3e511a8a9a284249929a988c2e263b762 https://github.com/pseudonymous/better-better-booru/commit/2b448ccaad5094f5c6886de70cc3b0b0477c4443