I’m pretty sure macOS safari doesn’t execute JavaScript on background windows/tabs.
When I play Bitburner, if I want to run it in the background, I have to run the game on Firefox or chrome. It’s a shame because safari actually gives best performance by quite a large margin.