• 0

.JS Opera Extension - URL Filter API


Question

Hey guys,

I need some assistance (as I am a total noob at this but fancied trying my hand)

I was trying to create an extension for Opera to Block all websites except a handful of white listed ones using the opera.extension.urlfilter

Working from the example here: http://dev.opera.com...url-filter-api/ I have the extension blocking all web sites '* ://*.*/*' tested and working.

The problem comes when I try and remove sites from the block list or add them to the allow (I have tried both ways) .block.remove and .allow.add in accordance with the API - http://dev.opera.com...-api-urlfilter/

The extension just continues to block everything. Could someone take a look and tell me wtf I am actually missing please :)


// Check that the URL Filter API exists
if (typeof opera.extension.urlfilter != 'undefined') {

// Put the sites we want to block in an array
var sites = ['*://*.*/*', '*://*.*.*'];

// Put the sites we want to remove in an array
var sitesremove = ['*://twitter.com/*', '*://*.twitter.com'];

// Asign the URLFilter object to a variable for efficiency
var filter = opera.extension.urlfilter;

// Loop through the array of sites and add each one to the "block" list
for (var i = 0, len = sites.length; i < len; i++) {
filter.block.add(sites[i]);

}

// Loop through the array of sites and add each one to the "remove" list
for (var i = 0, len = sitesremove.length; i < len; i++) {
filter.block.remove(sitesremove[i]);

}

}
[/CODE]

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.