Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spoofing the value of navigator.userAgent (possible solution) #10

Open
aarong416 opened this issue Jul 23, 2022 · 0 comments
Open

Spoofing the value of navigator.userAgent (possible solution) #10

aarong416 opened this issue Jul 23, 2022 · 0 comments

Comments

@aarong416
Copy link

I know there is already an issue for this open at #6, but it has since been closed and I am not able to reopen it, so I've created a new issue instead.

After reading the aforementioned issue, I did some research to see if it was possible to spoof the value of navigator.userAgent (and the related user agent identifying information on the navigator object itself), and it seems that it may be possible.

A possible solution to spoofing navigator.userAgent is by injecting a script into the page before anything else loads (so that websites' UA detection don't run before spoofing) which then modifies the navigator object itself.

I'm not familiar with creating an extension for Firefox, otherwise I would have created a reproducible example, but I found some resources that could be helpful in doing this:

This seems like a good place to start for injecting a script into a web page.

The injected script can modify the contents of the navigator object by using Object.defineProperty(...).

An example usage of Object.defineProperty(...):

Object.defineProperty(navigator, 'userAgent', {
value: 'Chrome',
writable: false
});

Doing navigator.userAgent in the console yields Chrome.

Note that there are still other properties on the navigator object that store individual user agent information, such as appCodeName and oscpu, so these will need to be modified in addition to navigator.userAgent.

I hope this helps in coming up with a solution to the problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant