Day 9: ua.ini

April 27, 2005

If you’ve used Opera for very long, then you’ve probably run into a website that claimed it wouldn’t work with Opera. Most of the time, it would work just fine, if the site didn’t discriminate against Opera.

Today we’ll look at a way to let you decide how Opera reports itself. Opera8 introduces ua.ini, a file which will let you control the user-agent which Opera reports.

What’s a user-agent? Every browser reports itself to every website that you visit. For example, your browser reports itself as CCBot/1.0 (+http://www.commoncrawl.org/bot.html) .

Why does this matter? Well, sit back and I’ll tell you. (If you already know about user-agent sniffing and are willing to raise your right hand and swear to God that you will never, ever be involved in User-Agent sniffing, you may skip down to Opera’s ua.ini options below.)

I think I have the details of this correct, if anyone knows of a site which has a better chronology, please let me know.

This story begins many years ago. Way back when, once upon a time, there was Netscape and Internet Explorer, and they were both pretty much the same. Then Netscape introduced a new feature. Websites started checking to see if you were using Internet Explorer or Netscape. If you were using Netscape, you were sent to one page, and if you were using Internet Explorer, you were sent to another… or you were given one of those dreaded (and dreadful) “This page designed for…” messages.

Eventually, Internet Explorer added support for that same feature, but it was too late. There were already websites checking to see if you were using Netscape. So what were they supposed to do?

Well, one could come up with various suggestions, but what Internet Explorer actually did was pretend to be Netscape. In fact, to this day, Internet Explorer still pretends to be Netscape, sort of. Here is what Internet Explorer 6 (from Windows XP) reports as the user agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)

Did you notice the first word is Mozilla? Why Mozilla? Because that’s what Netscape called itself. Yeah, later there was a browser suite called Mozilla that was the open source version of the browser based on Netscape. Confused yet? I haven’t even gotten started.

Over time, Internet Explorer grew to have features that Netscape didn’t have, so people started looking for Internet Explorer in the user agent. Then Netscape would add the feature, and more and more users were told “This site is designed for”.

“ARGH! Make it stop!” you scream. If only I could. So now we have sites that are checking for either Netscape or Internet Explorer. That’s bad enough. Then they started checking for version numbers, and users were told “This site is designed for X version 5.” Of course then Browser X would release version 6 and many of these sites didn’t check properly for “greater than 5” so it would break again.

Worse, there were also differences in Netscape for Mac and Netscape for Windows, and Internet Explorer for Mac and Internet Explorer for Windows. So now you’ve got people who are sniffing for the browser type, the browser version, and the version of the operating system. (We won’t even discuss the fact that Windows XP is called “Windows NT 5.1”)

“But wait!” you cry, in a vain attempt at hopefulness, “we have had two brand new browsers come on the scene in the past few years! Firefox and Safari! Surely now websites have figured out that they can’t just cater to a few browsers!”

Unfortunately that optimism is completely unfounded. Both of these browsers had to face the reality of the web as it exists, not some ideal. They couldn’t afford to have people shut out of websites because they were not using browser X. In fact, Firefox added a new keyword: Gecko:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3

So what did people do? They started to look for the word “Gecko” … Of course you can see where this is going. Safari decided that it liked the way that Firefox thought, so it was going to pretend to be Firefox, and included the word “Gecko” in its user-agent string:

Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/312.1 (KHTML, like Gecko) Safari/312

It should come as no surprise that Opera finds itself on a web where too many websites are only aware of Internet Explorer and Netscape.

Available Options

<

p> So what will Opera do? They could say “I’m Opera, let me in” but of course most sites won’t. So Opera also pretends. By default Opera pretends to be Internet Explorer. Pressing F12 will let you change the current identification (or you can set a default in Preferences → Advanced → Network Preferences.)

Mac Users: some sites are beginning to recognize the fact that once great IE/Mac is dead. I have already run into one site telling me I should use a newer browser. Oh, and FYI, not only does Firefox/Mac not report itself as Gecko based, it pretends to be IE 6, as you can see here: “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)”. All of which is to say that you may need this feature even more than Windows users.

The Opera8 changelog reports that the following options are available:

  1. Identify as Opera
  2. Identify as Mozilla
  3. Identify as Internet Explorer
  4. Identify as Mozilla, hide Opera ID completely
  5. Identify as Internet Explorer, hide Opera ID completely

Now 1, 2, and 3 are (I believe) the same as what you get if you make those choices via the F12 menu. What is new is 4 and 5, which come with the option of removing the word “Opera” from the User Agent string entirely.

By editing the ua.ini file you can trick sites into believing that you are using a different browser. Most of the time you will find that the sites work just fine, even if they told you that you had to use Netscape or Internet Explorer. This is highly recommended for just about any website run by Microsoft, especially MSN which has a history of blocking Opera for no reason.

How to use it

The file is fairly simple. Be sure Opera is not running before editing the file. The format is like this:

Opera Preferences version 2.0
; Do not edit this file while Opera is running
; This file is stored in UTF-8 encoding

[Identity]
www.opera.com=1
pncbank.com=4
online.wellsfargo.com=4
gmail.google.com=1
gmail.com=1
msdn.microsoft.com=2

Simply add entries in the same format.

Haavard wrote to let me know that Opera checks for updates to the file whenever you use the new Check for New Release feature (under the Help menu, which will talk about later), Opera also checks for a updates to the ua.ini file. This means that if you mess up your ua.ini file completely, you can delete it, restart Opera, and run Check For New Release and it will automatically be recreated!

Where to find the file

Mac users: use ~/Library/Preferences/Opera Preferences/. Windows and other users should check opera:about for the “Opera directory” (which usually ends with /profile/) and you will find the file in that directory.

“Why doesn’t Opera just remove the word ‘Opera’ from the F12 user agent strings?” Simply put, because if they did that, Opera would appear to disappear from the web. People who make websites would never see any of their visitors using Opera. Even as it is now, there is a good chance that a lot of sites are under-reporting Opera usage because they don’t properly check the user agent string.

Hopefully, Opera will soon introduce per-site preferences through the user interface, and you won’t have to edit an INI file to make these changes. It would be nice to manage these settings as simply (or more simply!) than you can edit cookies.

So that’s the ua.ini and why you need it and how to use it.

{ 21 comments… read them below or add one }

1 Optimizer 04.27.05 at 10:34 am

Freaking awesome. I’ve always been shut out of the Maxis SimCity site, but no longer (I’ve complained, to no avail). Added simcity.ea.com=5 to ua.ini and voila! As you might expect, the site renders perfectly. Opera: Thanks. Maxis: Shame on you.

I was also interested to learn that browsers other than Opera, like IE, pretend to be something they’re not. I thought that was particular to Opera. Now, it makes even less sense to me how Web sites underreport Opera usage. It shouldn’t be any harder to detect Opera users who are “pretending” to be IE than IE users “pretending” to be Netscape.

2 Peter Karlsson 04.27.05 at 4:29 pm

The whole “identify as” carousel started way back before Internet Explorer even existed. In the early days there basically was two graphical browsers, Mosaic, which was the first one, and Netscape (“Mozilla” as it was known internally, for “Mosaic meets Godzilla”, or something to that effect). Most other browsers were text-based.

So, with this great new graphical browser with support for a lot of new features, web sites wanted to take advantage of all the new stuff, while maintaining compatibility with those still running older browsers. So, what did they do? They let their web server software check if the user agent string said “Mozilla” and served the souped-up version, otherwise you got the plain no-frills version.

Enter Microsoft. They buy the rights to the Mosaic code-base and re-brand it Internet Explorer. The problem they’re seeing is that they’re not served the same rich content as Netscape gets, and while researching why they find that its because they don’t call themselves “Mozilla”. So they change their id to be “Mozilla compatible”, and they can now get the same stuff as Netscape gets, and everyone is happy (except for the poor people trying to do statistics, as they now need to differentiate between real Mozillas and fake ones).

When Internet Explorer gathers momentum, web sites start adapting to it, checking for the string “compatible” and “MSIE” in the user agent to serve special content.

Now Opera comes in, trying to do something sensible. Early versions identified themselves in a manner quite similar to Internet Explorer, claiming to be Netscape 3.0 “compatible”.

Then version 4 of Netscape and IE came out, and the content targetted for “pure” Netscape used started using a lot of Netscape-proprieratary stuff like layers to do fancy dynamical stuff. Opera did not support this, so identifying Opera as Netscape 4 caused some problems. After doing some research, Opera found that identifying as Internet Explorer (which itself identifies itself as Netscape) got “better” content, and started to do that.

That’s basically where we are today. Since pages mostly are written on the assumption that there only are two browsers, and sometimes what is written for one works with Opera, and sometimes the other, we have selectable user agent identifiers.

The strings without Opera are for the site that specifically target Opera as being an unsupported browser. This is mostly for webmasters who once tried Opera 3.0 and found it couldn’t do all the fancy stuff they wanted to do, and thus shut it out completely. Of course, five major versions later, Opera can handle their content, but they don’t want to believe that.

The best solution to the whole problem is of course to educate the webmasters into serve standards-compliant stuff that would work in all current browsers. But since that’s not likely to happen any time the nearest century, we are stuck with the situation we are in.

3 David Dernoncourt 04.28.05 at 2:13 am

I’ve been using this feature (change browser identity) since Opera 7.x, and when I saw “The ua.ini file allows Opera to pretend to be another browser” in the “30 days to becoming an Opera lover” section, I thought “Ah, finally they’ll let us completely edit how the browser reports itself”. For instance, I thought I’d be able to identify my Opera as Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6) [en] (that’s just an example, I know it doesn’t make much sense ;)). But then I realized it wasn’t this.

It would be a good idea to add this possibility, I mean, a file in which you can put the exact identifiaction string used by Opera. Or better, a file where you can put a list of identifiaction strings that you could switch with the F12 menu.

4 sgp 05.07.05 at 2:39 am

does ua.ini support wildcards, i.e., *.domain.com=4 ?

5 Sivakumar 05.10.05 at 3:02 am

I am from India and I have been using Opera since V 7 series. I recently upgraded to Opera 8 free cersion and also reading your post under 30 days to Become Opera8 Lover. I followed your instructions and still the indentification shows only first 3 options. I think I am some trick here. Kindly advise enabling me to get the 4 & 5 Option. I am desparate for it. In India, everything work on IE. I am bored of that. Pleasse let me know.

6 Richard Grevers 05.10.05 at 4:28 pm

Sivakumar, there isn’t any interface to edit ua.ini from within Opera (maybe there will be in the future). To use ID’s 4 and 5, you need to edit the file while Opera is not running.

However, if people report sites and ids which work to Opera, Opera will add them to their database and your ua.ini will be updated with settings for those sites when Opera checks for newer versions periodically. (The update will not delete your custom entries).

7 Adam Lightfoot 05.19.05 at 3:04 pm

Game over! I was pondering using Netscape 8 just because it “seemed” to be the only browser that would render IE only sites without actually opening IE(Firefox). I have two sites that I have to log into at work that did not work until I read this. Thanks again for the awesome info!

8 Mr.Jones 05.20.05 at 2:52 pm

Giving the users the ability to modify their identification string themselves (as mentioned in a post above) would not be such a good idea:

Imagine everyone identifying themselves as “Geekbrowser/9.9 (compatible; MSIE 6.66; Windows NT 6) [en]” or whatever, imagine what that would do to the logs of a webserver…

It’s nice of opera to let us pretend to be someone else for the IE optimized sites, but own identifiers would spoil it.

9 Andrew 05.22.05 at 2:37 am

Mr Jones said:

Giving the users the ability to modify their identification string themselves (as mentioned in a post above) would not be such a good idea

On the contrary; this would essentially force Web site authors into using W3C standards rather than proprietary extensions, because they could never know what browser their readers were using.

10 TjL (tntluoma.com) 05.22.05 at 7:16 am

I suspect that unless all browsers stopped sending a user-agent, letting the users set their own UA would have very little impact.

Indeed, on the rare occasions when I check my site logs, I usually see that someone has changed their UA to something like “NONEOFYOURBUSINESS” or “CODETOSTANDARDS” which has absolutely 0% impact on me because a) I do anyway (or try) and b) even if I didn’t, one random browser wouldn’t be enough for me to change my site.

One thing I failed to mention is that most browsers now have an HTTP-ACCEPT header which does tell you what the browser can/can’t handle. I wrote more about this when I was discussing application/xhtml+xml some time ago.

11 Stuart Holmes 06.11.05 at 5:54 pm

Wouldn’t it be neat if we could go arond identifying our favourite browser correctly as opera but have a magic button on the toolbar to temporarily change the ua.ini info only when essential to trick sites into thinking we have the latest m$ product?

Jam wouldn’t hurt either.

(that’s as in ‘you want jam on it too?!?’)

12 TjL (tntluoma.com) 06.11.05 at 9:33 pm

Stuart - that’s a great idea. I wish there was a way to do that, if for no other reason than to see if the site would work better with a spoofed UA.

Unfortunately there’s no way to do that (at least none that I am aware of).

13 Jack 07.03.05 at 5:38 pm

I just checked my ua.ini file. I have the line:

“www.sony.com=0”

What brower does “0” represent?

14 TjL (tntluoma.com) 07.04.05 at 1:22 am
15 Ruari 08.02.05 at 5:47 am

0 = Still under the control of F12 or Tools/Preferences/Advanced/Network


1 = Overrides F12 & TPAN and sends: Opera/8.02 (Windows NT 5.0; U; en)


2 = Overrides F12 & TPAN and sends: Mozilla/4.78 (Windows NT 5.0; U; en) Opera 8.02


3 = Overrides F12 & TPAN and sends: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; en) Opera 8.02


4 = Overrides F12 & TPAN and sends: Mozilla/5.0 (Windows NT 5.0; U; en; rv:1.7.5) Gecko/20041110


5 = Overrides F12 & TPAN and sends: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; en)


The email address this message was posted from is valid but will expire. If you want to contact me several days after my posting you can find a contact email address on http://ruari.com/

16 Martin 09.15.05 at 5:33 am

I didn’t get what Stuarts Problem was.

Having an Button for changing the UA-String is no Problem:

press “Shift+F12” go to “Buttons”, and then you have 2 possibilities: a Dropdown-Field, found under “Preferences” and an “Identify as”-Field found under “Status”.

The Dropdown-Field lets you select the UA directly, the “Status”-Field changes with every click (i prefer that one, because it fits better into my opery-skin).

That is sufficient for most of the Websites (until now i found only gettyimages.com which still told me to get another browser)

Unfortunately the UA-Strings 4 und 5 (Mozilla/IE without any mention of Opera) aren’t accessible through the userinterface, and i don’t now if there is any possibility of changing this.

Martin, with gettyimages.com now working fine after ua.ini-tuning

17 Alvin Brinson 09.20.05 at 3:16 pm

This is useless for sites that identify the browser through JavaScript.

Why hasn’t Opera come around and made an option to masquerade completely?

Until they do, any site that uses JavaScript to detect, such as the DSL portal at http://dsl.sbc.yahoo.com/ will fail to work no matter what.

See Here:

http://www.broadbandreports.com/forum/remark,14402348~mode=full~days=9999~start=20

18 Filbo 10.12.05 at 4:01 am

This userjs script attempts to masquerade “completely”. It should work for many sites which aren’t fooled by Opera’s standard ua.ini choices. It still won’t help sites which use browser and JS features which are absent in Opera. A few sites may use object detection of those features, so they’ll still detect and reject Opera.

Bela attempts to masquerade “completely”. It should work for many sites which aren’t fooled by Opera’s standard ua.ini choices. It still won’t help sites which use browser and JS features which are absent in Opera. A few sites may use object detection of those features, so they’ll still detect and reject Opera.

Bela<

19 Bernd Matzner 10.26.05 at 5:20 pm

The stupid thing is that because of Opera identifying itself as IE it totally messes up web statistics. I think a reason why Opera to this day isn’t taken seriously is that it ranks so low in web stats. Why bother taking 0.8% of the user agents into account when testing pages? I think today - with lots more standards-compliant websites around, it might be a good move to change that setting so it identifies itself as Opera by default.

20 TjL (tntluoma.com) 10.26.05 at 5:31 pm

Source: http://snapshot.opera.com/windows/w90p1.html

“Changed default UserAgent string to identify as Opera.”

21 jmd2121 02.19.06 at 12:14 am

opera has to catch up with the times. firefox now allows arbitrary userid strings. it’s turning into an issue now as many websites are allowing significant content differences based on user agent string.

((TjL adds: What sites? I’d like to know what sites are really blocking Internet Explorer))

For example, I’d like to have Googlebot/2.1 (+http://www.google.com/bot.html) on my list of available user agent strings as many sites allow unfettered access to googlebot.

I’d also rather stay with opera than use firefox

((TjL adds: Just because I’d like unfettered access to your checking account, does that mean I should get it?))

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post: Day 8: Fit to Window Width

Next post: Day 10: User JavaScript