Site patching

Web designers sometimes use non-standard tools and tricks to design their pages and only test these in specific browsers. This may cause pages to break in browsers for which they have not been tested.

Alternatively, some pages include fixes for bugs in Opera. When these bugs are fixed, however, the Web developer may not be aware of this, and will keep the original fixes. For example, a page that works well on Opera for desktop 6, may not work in Opera for desktop 9.

Site patching helps to avoid the frustration this situation causes.

What is Site patching?

Site Patching in Opera consists of two main parts; Browser JavaScript and Site preferences.

Browser JavaScript

Browser JavaScript is a collection of User JavaScripts that are developed and maintained by Opera Software. These scripts patch Web pages so that they are fully functional in Opera. Additionally, as some techniques are often reused by Web developers, a single patch may be applied to many Web pages.

The scripts are contained in the browser.js file, which is located in the OPERA_HOME directory, and is run for every Web page.

Warning: This file is signed, so do not attempt to modify it. Opera will only accept browser.js files that have been properly signed for security reasons.

For further information and a list of affected sites, see the Opera Browser JavaScript Web site. Please note that this list corresponds to the Browser JavaScript used on Opera for desktop, which differs slightly from what is used in the Opera for Devices

Site preferences

Site preferences allow you to customize Opera for a specific site without affecting the global behavior of Opera.

One common example is when a site has been verified to work with one or more browsers but, for some reason, it has not been tested with Opera. In these cases, some Web designers have a bad habit of only allowing access by the verified browsers, so although the site may work very well in Opera, it cannot be accessed with the Opera browser.

In this situation, site preferences is a very useful tool, as it can mask the user-agent string to something that the site recognizes and therefore allow access to the site in Opera.

These settings are controlled by the override.ini and override_downloaded.ini files in your OPERA_HOME directory. The override_downloaded.ini is maintained by Opera and updated alongside the Browser JavaScript file, while the override.ini can be manually edited.

Configure your own site preferences

The CDK is shipped with an override.ini sample, where settings can be added. The format of the file is as follows:

Example:

[Overrides] 
www.example.com
www.example.net

[www.example.com]
User Agent|Spoof UserAgent ID=3
User Prefs|Ignore Unrequested Popups=1

[www.example.net]
User Agent|Spoof UserAgent ID=4
Extensions|Plugins=0

Preferences that can be site-patched

[User Prefs]
Accept Cookies Session Only, Allow script to change status, Allow script to hide address, Allow script to receive right clicks, Always Load User JavaScript, Client Pull, Client Refresh, Enable Referrer, Enable Scrollbar Colors, Enable Styling On Forms, Force Encoding, Ignore Target, Ignore Unrequested Popups, Local CSS File, Target Destination, User JavaScript
[Extensions]
Frames Show Active, Frames, IFrames, Plugins, Scripting
[Multimedia]
Show Animation
[Network]
UTF8 Escape URLs
[User Agent]
Spoof UserAgent ID

How to use site-patching?

To configure Opera to use this feature, it must be enabled in your ini file. For information about how to do this, please see the Browser JavaScript topic in the opera.ini settings section.

How to get updated versions

There are two ways to get updated override_downloaded.ini and browser.js files. These are described in the next two topics.

Note: If using wget or similar software, be careful when downloading this file because the server responds with different files depending on the user agent string and may not work.

Automatic updates

When the Browser JavaScript feature is enabled, Opera will automatically check if there are any updated browser.js or override_downloaded.ini files available. The update check will take place shortly after startup, and then once a week, in case Opera has not been restarted. The reason for not checking directly at startup is to keep the startup time as minimal as possible.

This mechanism can be disabled via integration code, so some Opera Powered devices may not support Browser JS.