Spoofing UserAgent in Opera

Posted by PoweRoy on Stack Overflow See other posts from Stack Overflow or by PoweRoy
Published on 2010-05-20T11:53:49Z Indexed on 2010/05/20 12:10 UTC
Read the original article Hit count: 703

Filed under:
|
|

I'm trying to spoof Opera (under linux) to be an other browser, in this case iPad for some testing purposes. Now I know sites can check which browser is accessing the using for example in PHP $useragent = $_SERVER['HTTP_USER_AGENT']; and in javascript navigator.userAgent (or navigator.platform).

In firefox you can use an addon to easily switch your useragent and other relevant information, but in Opera it seems it bit hard to do.

First in opera.ini you can do:

[User Agent]
Spoof UserAgent ID=1

But this is limited to a predefined list of UserAgents. No room for custom ones.

Also in opera.ini

[ISP]
Id=iPad

This will add iPad to the User Agent of Opera. It's a start and works most of the time on the sites.

In opera.ini you can set a 'User JavaScript file' to load a custom JavaScript file before loading a website:

[User Prefs]
User JavaScript File=/opera_dir/userjs/load.js

In load.js you can do:

navigator.userAgent = "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10"

Because this file gets executed before loading the website I can modify the UserAgent, but this won't work when a site is checking the UserAgent via PHP, but it works for sites checking with Javascript)

So here's my question: is there another way of spoofing a complete custom UserAgent?

© Stack Overflow or respective owner

Related posts about opera

Related posts about spoofing