Mac compatibility

Added mac compatibility by checking userAgent.

Tested in chrome for windows and mac.