[Userscript] Forum: Details Keep Open State

:warning: This is a third-party script/app and is not created by the WaniKani team. By using this, you understand that it can stop working at any time or be discontinued indefinitely.

This UserScript to meant to keep [details] or <details> tags open while editing; a big problem for me while editing a Wiki, or an extra long thread, with a lot of collapses - opened and when edited, they close themselves.

The state is saved based on “title” / “summary”. Although duplicated titles also work, I don’t really recommend that.

That I can create this in the first place, is thanks to IME2Furigana.

Technical, and code reusability

The code is made from multiple files’ TypeScript, bundled together with esbuild (and using packages from NPM is also possible).

Coindentally, Vite comes together with esbuild, which can become useful when I need to test something on a real localhost website first.

The code is automatically built to JavaScript when commited to Github, so the latest code is here. Somehow, even after being built / bundled, the code is still very readable! :open_book: :boom:

Because of the multiple files’ TypeScript thing, a portion of IME2Furigana code is here. I don’t really know how window.require() of a Discourse Forum works, however; just copied everything. :grin:


This has annoyed me endlessly! :joy: Thank you for making this improvement in my forum life! :bowing_woman:


test test

whoa, it works! Super cool!

Nice! :durtle_love: My solution to this has been to delete one of the closing brackets and add it back when I’m done editing, hehe.

Like so:

Work in progress


Actually thought about writing this script so many times, but never got around to it, great work!


Anyone using Safari that this script works for? Just installed it and it doesn’t seem to work for me.

Does it throw any error in the console?

As long as you aren’t editing Details’ title, it should work.

Also posted to IME2furigana because that also doesn’t work. These are the errors I get (for both I suppose):

Actually, wait, maybe I should try looking at the console with detail tags and such. Give me a sec…


So now I have a test with a detail tag that does not stay open…

With detail tag in open reply window:

It might be possible to edit the script to not using Discourse API at all. I might try doing that later.