For privacy I always changed my useragent of browser regularly and it used to work. But lately changing useragent alone in browser dosen't prevent os fingerprinting. Tools like https://browserleaks.com can correctly guess my os eventhough I have used private mode with vpn, changed my useragent, disabled javascript and flash, added adblocker and other types of privacy extensions and manually hardened the browser. Even after this browserleaks knows my os.
How does os fingerprinting works in browsers and how to prevent it?