« Documentation Home

RuleOptions.excludeDomains

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.

Description:

An array of zero or more domains on which to not apply a given URL Filter rule.

This property is passed within a RuleOptions object as a parameter for URL Filter methods.

Syntax:

DOMString[] excludeDomains

Example:

The following example blocks any content from facebook.com, but only when accessed from the cnn.com domain, e.g. a "Like" or "Recommend" button.

<!-- 
  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') {
  // Set the options for the filter rule
  var ruleOptions = {
    excludeDomains: ['cnn.com']
  }
  
  // Assign the URLFilter object to a variable for efficiency
  var filter = opera.extension.urlfilter;
  
  filter.allow.add('||facebook.com/*', ruleOptions);
  filter.block.add('||facebook.com/*');
}

Note the use of || which is a hostname mark. This indicates that the subsequent characters should begin matching from any host name in the URL. For example, ||example.com* matches http://example.com/, https://www.example.com/, or similar. However, it will not match http://badexample.com/.