Skip to content

Commit

Permalink
Allow configuration of ignored domains (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
stoically committed Jun 27, 2019
1 parent 7b3c701 commit 6f5ebdf
Show file tree
Hide file tree
Showing 4 changed files with 315 additions and 203 deletions.
19 changes: 17 additions & 2 deletions src/core/background/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,27 @@ class Migration {
await this.storage.persist();
}
if (versionCompare('0.103', previousVersion) >= 0) {
debug('updated from version <= 0.103, possibly set deletesHistory.active');
debug('updated from version <= 0.103, migrate deletesHistory.active and ignoreRequestsTo');
const history = await browser.permissions.contains({permissions: ['history']});
if (history) {
this.storage.local.preferences.deletesHistory.active = true;
await this.storage.persist();
}

if (this.storage.local.preferences.ignoreRequestsToAMO === false) {
this.storage.local.preferences.ignoreRequests =
this.storage.local.preferences.ignoreRequests.filter(ignoredPattern =>
ignoredPattern !== 'addons.mozilla.org'
);
}
if (this.storage.local.preferences.ignoreRequestsToPocket === false) {
this.storage.local.preferences.ignoreRequests =
this.storage.local.preferences.ignoreRequests.filter(ignoredPattern =>
ignoredPattern !== 'getpocket.com'
);
}
delete this.storage.local.preferences.ignoreRequestsToAMO;
delete this.storage.local.preferences.ignoreRequestsToPocket;
await this.storage.persist();
}
}
}
Expand Down
15 changes: 5 additions & 10 deletions src/core/background/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,11 @@ class TmpRequest {

this.container.maybeAddHistory(tab, request.url);

if ((request.url.startsWith('http://addons.mozilla.org') ||
request.url.startsWith('https://addons.mozilla.org')) &&
this.storage.local.preferences.ignoreRequestsToAMO) {
debug('[_webRequestOnBeforeRequest] we are ignoring requests to addons.mozilla.org because we arent allowed to cancel requests anyway', request);
return;
}

if (request.url.startsWith('https://getpocket.com') &&
this.storage.local.preferences.ignoreRequestsToPocket) {
debug('[_webRequestOnBeforeRequest] we are ignoring requests to getpocket.com because of #52', request);
if (this.storage.local.preferences.ignoreRequests.length &&
this.storage.local.preferences.ignoreRequests.find(ignorePattern => {
return this.isolation.matchDomainPattern(request.url, ignorePattern);
})) {
debug('[_webRequestOnBeforeRequest] request url is on the ignoreRequests list', request);
return;
}

Expand Down
3 changes: 1 addition & 2 deletions src/core/background/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ class TmpStorage {
delay: 2000,
domains: ['t.co', 'outgoing.prod.mozaws.net']
},
ignoreRequestsToAMO: true,
ignoreRequestsToPocket: true,
ignoreRequests: ['getpocket.com', 'addons.mozilla.org'],
cookies: {
domain: {}
},
Expand Down
Loading

0 comments on commit 6f5ebdf

Please sign in to comment.