How can I add a custom (my own) JS widget/code to the end of the first post in the topic?
Have a look at Developer’s guide to Discourse Themes.
Thanks, I saw it. But it didn’t help me, that’s why I created this thread.
For security reasons, Discourse doesn’t accept JS in post content. So you have two options:
If the widget you need can be embedded, use that. It’s what we do for Youtube, Codepen, Typeform, and many more.
Write (or commission someone to write it for you) a component/plugin
If you can’t embed it, you will need either a plugin or a theme-component. The guide linked above teaches you how to start, but you can also describe what you need in detail in the #marketplace category to commission it.