firefoxadbsettingsweb-idekaios

How do I change the user agent of a device in Kaiosrt or WebIDE?


I can see the following fields in “Device Preferences”.

Device Preferences

However, none of these preferences seem to control navigator.userAgent. I also tried looking into “Device Settings” but that doesn't have any field related to the user agent at all.

Device Settings

For reference, here is my runtime info.

Runtime Info

As you can see, the user agent is Mozilla 5.0 (Mobile; rv:48.0) Gecko/48.0 Firefox/48.0. I want to change the user agent to Mozilla/5.0 (Mobile; LYF/LF-2403/LYF-LF2403-000-01-3D-191217-i;Android; rv:48.0) Gecko/48.0 Firefox/48.0 KAIOS/2.0 to match the device user agent.


Solution

  • The trick is to treat it like a firefox browser:

    1. Open "Device Preferences" and add a new string config with key general.useragent.override and value as whatever you need.
    2. Restart your app in the simulator.

    The overriden user agent in step 1 should start reflecting.