[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:

17 Likes

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

3 Likes
Summary

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:

[details=“Summary”]
Work in progress
[/details

3 Likes

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

same!

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…

Testing

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.

@NeoArcturus I have no idea the script is still working, considering Emoter and IME2Furigana.

It can probably still be fixed, though.

At least, DOM manipulation doesn’t seem to work due to Discourse using Ember.js.

1 Like
This is a summary

This is a summery

Yeah, doesn’t appear to work…

Here’s what I get when I take a look at the console:

I hope it can be fixed, because I’m literally going crazy everytime I want to write my translations lol, this script would be so useful and make my life quality in the forums so much better

I vent around this by not closing the summary, i.e. taking away the last bracket ] and then insert it back when I’m done editing.

Edit: ah, leebo’d by my past self?? :rofl:

2 Likes

What is this leebo’d thing?

1 Like

It’s when you’re writing a reply to someone’s question, but someone else manages to post their answer first before you’ve posted yours. Originates from Leebo usually posting faster than everyone. His answer is usually better as well.

2 Likes