# Firefox add-on problem!

**URL:** <https://discourse.mozilla.org/t/firefox-add-on-problem/2375>\
**Category:** Development\
**Created:** [June 19, 2015, 12:35am UTC](https://discourse.mozilla.org/t/firefox-add-on-problem/2375 "2015-06-19T00:35:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![stop\_it\_be](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/stop_it_be/32/50561_2.png) [@stop\_it\_be](https://discourse.mozilla.org/u/stop_it_be)\
**Post date:** [June 19, 2015, 12:35am UTC](https://discourse.mozilla.org/t/firefox-add-on-problem/2375/1 "2015-06-19T00:35:47Z")

</div>

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](http://www.url01.com)’,  
‘[url01.com](http://url01.com)’,  
etc…  
];

var observers = {  
‘http-on-modify-request’: {  
observe: function (aSubject, aTopic, aData) {  
[console.info](http://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](https://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();  
}  
}

---

<div class="post-metadata">

**Author:** ![ondrejd](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/ondrejd/32/21013_2.png) [@ondrejd](https://discourse.mozilla.org/u/ondrejd)\
**Post date:** [June 19, 2015, 7:26pm UTC](https://discourse.mozilla.org/t/firefox-add-on-problem/2375/2 "2015-06-19T19:26:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stop\_it\_be](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/stop_it_be/32/50561_2.png) [@stop\_it\_be](https://discourse.mozilla.org/u/stop_it_be)\
**Post date:** [June 19, 2015, 9:18pm UTC](https://discourse.mozilla.org/t/firefox-add-on-problem/2375/3 "2015-06-19T21:18:21Z")

</div>

Ondřej Doněk Hey Thanks a lot, im completly new to all of that you know 😃 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

```

- License, v. 2.0. If a copy of the MPL was not distributed with this

- file, You can obtain one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). --\>  
  
  
em:id[Stop-it.be@hotmail.com](mailto:Stop-it.be@hotmail.com)\</em:id\>  
em:version1.5.59\</em:version\>  
em:type2\</em:type\>  
em:bootstraptrue\</em:bootstrap\>  
em:unpacktrue\</em:unpack\>

It is complet to help me to achive that??

thanks a lot

---

<div class="post-metadata">

**Author:** ![ondrejd](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/ondrejd/32/21013_2.png) [@ondrejd](https://discourse.mozilla.org/u/ondrejd)\
**Post date:** [June 19, 2015, 10:01pm UTC](https://discourse.mozilla.org/t/firefox-add-on-problem/2375/4 "2015-06-19T22:01:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![stop\_it\_be](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/stop_it_be/32/50561_2.png) [@stop\_it\_be](https://discourse.mozilla.org/u/stop_it_be)\
**Post date:** [June 20, 2015, 1:01am UTC](https://discourse.mozilla.org/t/firefox-add-on-problem/2375/5 "2015-06-20T01:01:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stop\_it\_be](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/stop_it_be/32/50561_2.png) [@stop\_it\_be](https://discourse.mozilla.org/u/stop_it_be)\
**Post date:** [June 21, 2015, 11:00am UTC](https://discourse.mozilla.org/t/firefox-add-on-problem/2375/6 "2015-06-21T11:00:27Z")

</div>

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 😃

---

<div class="post-metadata">

**Author:** ![ondrejd](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/ondrejd/32/21013_2.png) [@ondrejd](https://discourse.mozilla.org/u/ondrejd)\
**Post date:** [June 21, 2015, 3:10pm UTC](https://discourse.mozilla.org/t/firefox-add-on-problem/2375/7 "2015-06-21T15:10:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stop\_it\_be](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/stop_it_be/32/50561_2.png) [@stop\_it\_be](https://discourse.mozilla.org/u/stop_it_be)\
**Post date:** [June 21, 2015, 3:16pm UTC](https://discourse.mozilla.org/t/firefox-add-on-problem/2375/8 "2015-06-21T15:16:46Z")

</div>

yes of course im interrested 😃 wih your great help 😃 my email is: [stop-it.be@hotmail.com](mailto:stop-it.be@hotmail.com) 😃 i CAN’T find your email :s

---

<div class="post-metadata">

**Author:** ![ondrejd](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/ondrejd/32/21013_2.png) [@ondrejd](https://discourse.mozilla.org/u/ondrejd)\
**Post date:** [June 22, 2015, 9:23pm UTC](https://discourse.mozilla.org/t/firefox-add-on-problem/2375/9 "2015-06-22T21:23:29Z")

</div>

> [@stop\_it\_be](#):
>
> [stop-it.be@hotmail.com](mailto:stop-it.be@hotmail.com)

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

---

<div class="post-metadata">

**Author:** ![stop\_it\_be](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/stop_it_be/32/50561_2.png) [@stop\_it\_be](https://discourse.mozilla.org/u/stop_it_be)\
**Post date:** [April 8, 2017, 7:41am UTC](https://discourse.mozilla.org/t/firefox-add-on-problem/2375/11 "2017-04-08T07:41:51Z")

</div>

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](http://google.com), hwen the user tries to reach a website listed on my add-on.

```
(function() {

```

var AUTHORIZED\_DOMAINS= {

“[www.badurl1.com](http://www.badurl1.com)”: false,  
“[badurl1.com](http://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](http://google.com) instead of CANCEL???

thanks again  
😃
