This documentation relates to Opera's now deprecated .oex Extension API framework for Opera versions <= 12.15 and also provided by our OEX2NEX shim library.
For the latest Opera Extensions API documentation for Opera versions > 12.15 please consult the latest Opera Extensions API documentation online.
Enables special characters to be used for more flexible filtering. Note that all pattern matching is case sensitive.
*
matches any character.
||
matches the beginning of any hostname.
^
matches a single character from the following list:
! " # $ & ' ( ) * + , / : ; < = > ? @ [ \ ] ^ ` { | } ~
In other words, ||
matches any character in the ASCII subset that is not a letter, a digit, or one of the following:
_ - . %
For example, ||example.com^
will match match http://example.com:8080/, http://example.com/, https://subdomain.example.com/, etc. but not http://example.com.evil.com because ^
doesn't match .
(period).
This example shows how we can convert whitelisting in Adblock Plus syntax to the Opera URL Filter syntax. The whitelisting rule will allow scripts from the ||ads.cnn.com/js.ng/*&cnn_intl_subsection=download
URL and is taken from this list: https://easylist-downloads.adblockplus.org/easylist.txt
<!--
The configuration file ('config.xml').
-->
<?xml version='1.0' encoding='utf-8'?>
<widget xmlns="http://www.w3.org/ns/widgets">
...
<feature name="opera:urlfilter"/>
</widget>
//
// The background process (e.g. index.html)
//
// Check that the URL Filter API exists
if (typeof opera.extension.urlfilter != 'undefined') {
// Assign the URLFilter object to a variable for efficiency
var filter = opera.extension.urlfilter;
filter.block.add('||ads.*');
// The following is the same as this Adblock syntax for whitelisting:
// @@||ads.cnn.com/js.ng/*&cnn_intl_subsection=download$script
filter.allow.add("||ads.cnn.com/js.ng/*&cnn_intl_subsection=download", {resources: filter.RESOURCE_SCRIPT});
}