I have an program that displays content on web browsers via a localhost address. My program is cross-platform and I need to know what OS the browser is running on Windows for my program to operate correctly. I can do that by entering the following command into the browser's dev-tools console:
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
How can I automate this in my program? I don't know what browser users will be using, or even what OS they'll be on. The reason I can't know what the OS is ahead of time is because of the Windows build. This is done on the Windows Subsystem for Linux which means that the user's browser could be in Ubuntu or (more likely) in Windows. I need to know which one it is to save files correctly.