And again, good day.

The question, at first glance, may seem strange, but nonetheless:

"How can Chrome browser extension tools embed arbitrary javascript code into all tabs and frames that can be opened, and moreover, execute it first and foremost, before the DOM is ready? And another important condition is that this code must successfully acquire arbitrary data from the expansion itself to how it is embedded. "

And now a little more. There is an extension that replaces the browser's User-Agent. In the headers of requests, the substitution occurs successfully, but as soon as it comes to checking with JS tools on arbitrary sites, this is where the problems begin, as it is worth referring to naviganor.userAgent - as the real one immediately lights up.

Solution method - even before the readiness of the DOM to execute on all opened pages (and frames) something like:

navigator.__defineGetter__('userAgent', function(){ return 'foo' // customized user agent }); 

Where 'foo' should be obtained from the application settings. If you simply inject a js-file with similar code into all pages - we will execute the substitution of UserAgent, but we will not be able to get the value that needs to be substituted.

Tell me, please, your thoughts on this issue?

  • Offhand, Tampermonkey tried? - therainycat
  • And what is the connection in writing the extension and Tampermonkey? - Tarampampam
  • The question "... means of expansion ...". Tampermonkey - extension. Not that? - specify the question - therainycat
  • By means of its extension, on js - Tarampampam

0