That link is for something else that's also named Twine.
The Twine 1 editor is built in Python. Version 2 is 100% built on web technologies, as far as I know. Regardless, even in Twine 1, the compiled file contains no Python code itself; the story you generate is an html file.
It's probably possible to use Twine as a component in some project that uses another language, but there's really no native support in Twine for this.
If you want to do the things you described but don't want to use macros or TwineScript (nothing you described seems impossible in Twine) then you should probably try a different story format, like SugarCube or Snowman, as Harlowe doesn't really have any JavaScript API.