Remove moz-extension:* paths from capture. Fixes #49. (#62)

This commit is contained in:
Bianca Danforth 2017-06-19 07:18:30 -07:00 коммит произвёл Jonathan Kingston
Родитель 64a3b81a80
Коммит f560f2c213
2 изменённых файлов: 20 добавлений и 8 удалений

Просмотреть файл

@ -10,10 +10,25 @@ const capture = {
addListeners() {
// listen for each HTTP response
browser.webRequest.onResponseStarted.addListener(
this.sendThirdParty,
(response) => this.sendThirdParty(response),
{urls: ['<all_urls>']});
// listen for tab updates
browser.tabs.onUpdated.addListener(this.sendFirstParty);
browser.tabs.onUpdated.addListener(
(tabId, changeInfo, tab) => {
this.sendFirstParty(tabId, changeInfo, tab);
});
},
// Returns true if the request should be stored, otherwise false.
shouldStore(tab) {
const documentUrl = new URL(tab.url);
// ignore about:*, moz-extension:* & non-visible tabs (like dev tools)
if (documentUrl.protocol !== 'about:'
&& documentUrl.protocol !== 'moz-extension:'
&& tab.id !== browser.tabs.TAB_ID_NONE) {
return true;
}
return false;
},
// capture third party requests
@ -23,7 +38,8 @@ const capture = {
const targetUrl = new URL(response.url);
const originUrl = new URL(response.originUrl);
if (targetUrl.hostname !== documentUrl.hostname) {
if (targetUrl.hostname !== documentUrl.hostname
&& this.shouldStore(tab)) {
const data = {
document: documentUrl.hostname,
target: targetUrl.hostname,
@ -41,10 +57,7 @@ const capture = {
// capture first party requests
sendFirstParty(tabId, changeInfo, tab) {
const documentUrl = new URL(tab.url);
// ignore about:* pages and non-visible tabs
if (tab.status === 'complete'
&& documentUrl.protocol !== 'about:'
&& tabId !== browser.tabs.TAB_ID_NONE) {
if (tab.status === 'complete' && this.shouldStore(tab)) {
const data = { faviconUrl: tab.favIconUrl };
store.setFirstParty(documentUrl.hostname, data);
}

Просмотреть файл

@ -25,7 +25,6 @@
"background": {
"scripts": [
"js/store.js",
"js/capture.js",
"js/store.js",
"js/viz.js",