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 reports that the following options are available:
- Identify as Opera
- Identify as Mozilla
- Identify as Internet Explorer
- Identify as Mozilla, hide Opera ID completely
- 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 .
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.
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.