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();
}
}