Is it possible to use user agent to detect the platform and put all these codes into the js file?