That’s a 3 years old issue:
Right now (in MSFS 2024), to have some .JS code that can always run without being affected by the toolbar or having to run inside an airplane gauge, you should do an EFB app.
Let’s hope we won’t see a proliferation of “fake” EFB apps, existing for the sole purpose of providing a bridge to .JS to some other application, in the same fashion as the already happening proliferation of “fake” WASM modules, existing for the sole purpose of providing a bridge for the all important execute_calculator_code() call, which has even been deemed deprecated without a proper replacement.