Developers › Dev.Opera

RuleOptions.thirdParty

May 16, 2012 · by Opera Software

This functionality is currently in production, and only available to test in an experimental build of Opera desktop. To download the experimental build, see Desktop build with new extension APIs: Screenshot, Resource Loader and URL Filter.

Description:

A boolean property specifying whether a given URL Filter rule should apply to third-party domains. The value true indicates that only domains with a different origin are matched by this option. The value false indicates that only domains with the same origin are matched by this option. The value null, or if the thirdParty property is not specified, indicates that all domains are matched by this option.

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

Syntax:

boolean thirdParty

Example:

The following example blocks any content from the facebook.com domain, but only when it's included in a web page as third-party code, i.e. in non-facebook.com domains.

<!-- 
  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 = {
    thirdParty: true
  }
  
  opera.extension.urlfilter.block.add('||facebook.com/*', ruleOptions);
}

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/.

About this article

Published inDev.Opera
DateMay 16, 2012
AuthorOpera Software
Tagsextensions API, URL filter
OriginalInternet Archive