i've been using this trick for a while now for games that don't run in the background. this only works for windows. the steps are as follows.
- download Microsoft PowerToys https://learn.microsoft.com/en-us/windows/powertoys/install
- open it and enable the 'Always On Top' feature (if it isn't already)
- put your game on a separate window and do ctrl + windows + t
- make the window long but small vertically
- drag it so only the top left corner is sticking out from the right of your screen
- double click this corner to make it maximised. double click it again to put it back where it was and get back to what you were doing.
since a tiny little bit of the window is still visible on screen, the javascript still works :3. this probably isn't for everyone but it's worked well for me. hope this was helpful!!!