简体   繁体   中英

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

I can see the following fields in “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.

设备设置

For reference, here is my 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM