# Add-on BUG URGENT!

**URL:** <https://discourse.mozilla.org/t/add-on-bug-urgent/35052>\
**Category:** Development\
**Created:** [January 13, 2019, 11:45pm UTC](https://discourse.mozilla.org/t/add-on-bug-urgent/35052 "2019-01-13T23:45:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leonardo\_Sedevcic](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/leonardo_sedevcic/32/19893_2.png) [@Leonardo\_Sedevcic](https://discourse.mozilla.org/u/Leonardo_Sedevcic)\
**Post date:** [January 13, 2019, 11:45pm UTC](https://discourse.mozilla.org/t/add-on-bug-urgent/35052/1 "2019-01-13T23:45:15Z")

</div>

hi, i have a huge problem with my add-on i use:  
‘use strict’;

let db = []; // session Global

// ----- parse & cache the database data  
fetch(‘[https://www.stop-it.be/upload/myfile.dat](https://www.stop-it.be/upload/myfile.dat)’)  
.then(response =\> response.text())  
.then(text =\> { db = text.trim().split(/[\r\n]+/); })  
.catch(error =\> console.log(error));

chrome.webRequest.onBeforeRequest.addListener( details =\> {

```
let url = new URL(details.url);
return { cancel: url && url.hostname && db.includes(url.hostname) };

```

},  
{urls: [“http://_/_”, “https://_/_”]},  
[“blocking”]  
);

BUT urls just ‘[xxx.com](http://xxx.com)’ url’s, inside the “myfile.dat” are no more blocked by my add-on do someone know why something is wrong??

myfile.dat is not the real name of my file, it’s just for explaining the error i have.  
it’s URGENT !!!  
Thanks

---

<div class="post-metadata">

**Author:** ![freaktechnik](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/freaktechnik/32/37766_2.png) [@freaktechnik](https://discourse.mozilla.org/u/freaktechnik)\
**Post date:** [January 13, 2019, 11:47pm UTC](https://discourse.mozilla.org/t/add-on-bug-urgent/35052/2 "2019-01-13T23:47:43Z")

</div>

Could you please try to format your post properly with code blocks if it is this urgent? It really helps with being able to read the code.

Further, `myfile.dat` has the format of one hostname per line?

---

<div class="post-metadata">

**Author:** ![Leonardo\_Sedevcic](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/leonardo_sedevcic/32/19893_2.png) [@Leonardo\_Sedevcic](https://discourse.mozilla.org/u/Leonardo_Sedevcic)\
**Post date:** [January 13, 2019, 11:59pm UTC](https://discourse.mozilla.org/t/add-on-bug-urgent/35052/3 "2019-01-13T23:59:03Z")

</div>

```
'use strict';

let db = []; // session Global

// ----- parse & cache the database data
fetch('https://www.stop-it.be/upload/myfile.dat')
.then(response => response.text())
.then(text => { db = text.trim().split(/[\r\n]+/); })
.catch(error => console.log(error));

chrome.webRequest.onBeforeRequest.addListener( details => {

let url = new URL(details.url);
return { cancel: url && url.hostname && db.includes(url.hostname) };
}, 
{urls: ["http://*/*", "https://*/*"]},
["blocking"]
);

```

so here its my code inside the background.js

inside myfile.dat i just have urls in plain/text format like

[badurl01.com](http://badurl01.com)  
[www.badurl1.com](http://www.badurl1.com)  
[badurl02.com](http://badurl02.com)  
[www.badurl2.com](http://www.badurl2.com)

etc…

---

<div class="post-metadata">

**Author:** ![freaktechnik](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/freaktechnik/32/37766_2.png) [@freaktechnik](https://discourse.mozilla.org/u/freaktechnik)\
**Post date:** [January 14, 2019, 12:01am UTC](https://discourse.mozilla.org/t/add-on-bug-urgent/35052/4 "2019-01-14T00:01:26Z")

</div>

How far have you gone with investigating this? For example, is db already fully loaded when you are loading your URL and expecting it to be canceled? Have you looked at what the hostname is in the onBeforeRequest listener?

---

<div class="post-metadata">

**Author:** ![Leonardo\_Sedevcic](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/leonardo_sedevcic/32/19893_2.png) [@Leonardo\_Sedevcic](https://discourse.mozilla.org/u/Leonardo_Sedevcic)\
**Post date:** [January 14, 2019, 12:09am UTC](https://discourse.mozilla.org/t/add-on-bug-urgent/35052/6 "2019-01-14T00:09:45Z")

</div>

if i type for example on firefox or chrome the name of a xxx site without the .com, .xxx etc nothing appears,

BUT if i type the full name of a xxx site for example [www.xxxxx.com](http://www.xxxxx.com) or [xxxxx.com](http://xxxxx.com) it’s not blocked and i access to it :s

domains names are not blocked aymore :s  
if i add the myfile.dat file inside the xpi file it works, but i dont want the huge database of bad urls be included inside the add-on, not safe for users

i’m shaking like and old tree :s hope to solve that :s

---

<div class="post-metadata">

**Author:** ![Leonardo\_Sedevcic](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/leonardo_sedevcic/32/19893_2.png) [@Leonardo\_Sedevcic](https://discourse.mozilla.org/u/Leonardo_Sedevcic)\
**Post date:** [January 14, 2019, 11:41am UTC](https://discourse.mozilla.org/t/add-on-bug-urgent/35052/7 "2019-01-14T11:41:22Z")

</div>

so i changed the manifest and did this:

```
"background": {
"scripts": ["background.js","search.js"],
"persistent": true
},
"browser_action":{ 
"browser_style": true, 
"default_icon":"Icon-48.png",
"default_popup":"popup.html"
},
"icons":{  
"48":"Icon-48.png"
},
"manifest_version":2,
"name":"Stop-it",
"permissions":[  
"http://*/*",
"https://*/*",
"webRequest",
"webNavigation",
"cookies",
"*://*.google.com/",
"*://*.duckduckgo.com/",
"*://*.yahoo.com/",
"*://*.yandex.com/",
"*://*.bing.com/",
"webRequestBlocking",
"<all_urls>"
],
"author":"Leonardo Sedevcic",
"version":"1.9.79",
"description":"The BEST Anti Porn, parental filter, betting & casinos, 
PornCams tool on the web, and many more",
"applications":{  
"gecko":{  
"id":"Stop-it.be@hotmail.com",
"strict_min_version":"52.0"
}
}
}

```

My add-on works under Chrome urls are blocked from  
fetch(‘[https://www.stop-it.be/upload/dburl.dat](https://www.stop-it.be/upload/dburl.dat)’)

but under firefox it doesnt work !!!

my background file looks like:

```
'use strict';

let db = []; // session Global

// ----- parse & cache the database data
fetch('https://www.stop-it.be/upload/dburl.dat')
.then(response => response.text())
.then(text => { db = text.trim().split(/[\r\n]+/); })
.catch(error => console.log(error));

chrome.webRequest.onBeforeRequest.addListener( details => {

let url = new URL(details.url);
return { cancel: url && url.hostname && db.includes(url.hostname) };
}, 
{urls: ["http://*/*", "https://*/*"]},
["blocking"]
);
```

---

<div class="post-metadata">

**Author:** ![jscher2000](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/jscher2000/32/28202_2.png) [@jscher2000](https://discourse.mozilla.org/u/jscher2000)\
**Post date:** [January 14, 2019, 5:12pm UTC](https://discourse.mozilla.org/t/add-on-bug-urgent/35052/8 "2019-01-14T17:12:22Z")

</div>

There’s a different thread that starts with “Hi i solved my proble for my add-on but i get in a new problem!”

Does that mean you can close this thread? Do you want to mention any lesson learned for others who have the same isue?

---

<div class="post-metadata">

**Author:** ![Leonardo\_Sedevcic](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/leonardo_sedevcic/32/19893_2.png) [@Leonardo\_Sedevcic](https://discourse.mozilla.org/u/Leonardo_Sedevcic)\
**Post date:** [January 14, 2019, 7:25pm UTC](https://discourse.mozilla.org/t/add-on-bug-urgent/35052/9 "2019-01-14T19:25:39Z")

</div>

Solved, i hosted the database in another domain name, now my add-on block request from the db and also prevent users to access to the db.

Thanks to everyone !
