0

I am trying to override navigator.useragent with a chrome extension. I see examples where people call the script to run in v2 extensions, but I don't know with CSP if that is possible with v3. I have a v3 extension and want to add this new feature, but I don't know if the content script can redefine it, if I need to inject a script somehow (and get it past CSP), or if there is something else to do.

I would like to append the word "Test" to the user agent retrieved in the app by navigator.useragent and also in the headers that get sent, but I am focused on the first half of the problem first.

Jason Hocker
  • 6,879
  • 9
  • 46
  • 79
  • You can use the same solutions with the only difference that in ManifestV3 you'll need to use a separate js file to run in the page context, see [method 1 here](https://stackoverflow.com/a/9517879). It also means that your script may run after the first script of the page saw the unpatched userAgent. It'll be fixed when ManifestV3 implements the ability to register scripts in the "main world". – wOxxOm Oct 09 '21 at 05:38
  • Is their a roadmap of something I could share when v3 "registers scripts in the main world" – Jason Hocker Oct 13 '21 at 13:31
  • Not yet, https://crbug.com/1054624. – wOxxOm Oct 13 '21 at 13:55

0 Answers0