Firefox add-on problem!

Hello to all
i have developed an add-on for mozilla firefox, it blocks bad urls and contents.
Now it is used by more than 30.000 people and still growing.

Every time i do an update everything goes fine.

but the team review asked me this:

could you please put the database in a separate file, or even better make it remote, downloadable at intervals or cached, so we don’t have to deal with this huge bootstrap.js (which make reviews painful because it disables online diffs) and you don’t need to resubmit the add-on for review every time the data changes?

Like i said, i dont know how to achive that!

Actualy i have all my huge database 6mb inside the bootstrap.js and its problematic.

So i need people around this for helping me to achive and make my add-on better.

here its my bootstrap.js code (without 6mb of urls)

const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;

Cu.import(‘resource://gre/modules/Services.jsm’);

var urls_block = [ //if urls contain any of these elements they will be blocked or redirected, your choice based on code in observer line 17
www.url01.com’,
url01.com’,
etc…
];

var observers = {
‘http-on-modify-request’: {
observe: function (aSubject, aTopic, aData) {
console.info('http-on-modify-request: aSubject = ’ + aSubject + ’ | aTopic = ’ + aTopic + ’ | aData = ’ + aData);
var httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
var requestUrl = httpChannel.URI.spec;
for (var i=0; i<urls_block.length; i++) {
if (requestUrl.indexOf(urls_block[i]) > -1) {
//httpChannel.cancel(Cr.NS_BINDING_ABORTED); //this aborts the load
httpChannel.redirectTo(Services.io.newURI(‘data:text,ILLEGAL_&_DANGEROUS_CONTENT_BLOCKED’, null, null)); //can redirect with this line, if dont want to redirect and just block, then uncomment this line and comment out line above (line 17)
break;
}
}
},
reg: function () {
Services.obs.addObserver(observers[‘http-on-modify-request’], ‘http-on-modify-request’, false);
},
unreg: function () {
Services.obs.removeObserver(observers[‘http-on-modify-request’], ‘http-on-modify-request’);
}
}
};

function install() {}

function uninstall() {}

function startup() {
for (var o in observers) {
observers[o].reg();
}
}

function shutdown(aData, aReason) {
if (aReason == APP_SHUTDOWN) return;

for (var o in observers) {
observers[o].unreg();
}
}

Hi,
I suggest this:

  1. move database to separate JSON file
  2. in install method (when reason is ADDON_INSTALL) put code to download remote JSON file which will be stored in user’s profile directory
  3. in startup method should be code that checks version of local and remote database and performs update of database if needed
  4. in uninstall method should be code that deletes database when the reason is ADDON_UNINSTALL

And that is all.

Regards,
Ondřej Doněk

1 Like

Ondřej Doněk Hey Thanks a lot, im completly new to all of that you know :smiley: can you help me to achive all of that??
in my add-on i have nothing, just a bootstrap.js and install.rdf.
inside the install i have:

<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public

It is complet to help me to achive that??

thanks a lot

I downloaded your add-on and saw the code… do you have it on GitHub or BitBucket so I can fork it and update the code?

2 Likes

Nope i dont have a github account :s BUT if you can help me to update the code thats fantastic :smiley: going to add your name on my website :smiley: because its so important for me and also for the Firefox review team :smiley: Also dont share my database please :smiley:

A this moment im working on a new updateof my website your help is going to be great for my add-on and the futures updates :smiley:

I saw that and I think the best start is on web - you need to prepare simple script that will provides data with links to all of your add-ons.

If you’re interested write me on my email.

Regards,
Ondřej Doněk

1 Like

yes of course im interrested :smiley: wih your great help :smiley: my email is: stop-it.be@hotmail.com :smiley: i CAN’T find your email :s

Sorry for slow response, I didn’t realize that you can’t see my email… check your mail box :wink:

hi ondrejd

do you know how can i do this, i have my chrome extension who block urls, at the moment my extension block urls and does not redirect teh user, what i would like to achive is, i would like to redirect the user to google.com, hwen the user tries to reach a website listed on my add-on.

(function() {

var AUTHORIZED_DOMAINS= {

www.badurl1.com”: false,
badurl1.com”: false

};
function extract_domain(url) {
var matches = url.match(/^https?://([^/?#]+)(?:[/?#]|$)/i);
return matches[1];
}

chrome.webRequest.onBeforeRequest.addListener(function(details) {
var domain = extract_domain(details.url);
return { cancel: AUTHORIZED_DOMAINS[domain ]===false };
}, {urls: ["<all_urls>"]},[“blocking”]);})();

do you know how i can do a redirection to google.com instead of CANCEL???

thanks again
:smiley: