mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-04 18:19:38 +02:00
#475: whitelist behind-the-scene by default
This commit is contained in:
parent
4b2dced6f4
commit
4c7f4771e2
@ -277,12 +277,11 @@ var onMessage = function(request, sender, callback) {
|
||||
break;
|
||||
|
||||
case 'toggleNetFiltering':
|
||||
µb.toggleNetFilteringSwitch(
|
||||
request.url,
|
||||
request.scope,
|
||||
request.state
|
||||
);
|
||||
µb.updateBadgeAsync(request.tabId);
|
||||
var pageStore = µb.pageStoreFromTabId(request.tabId);
|
||||
if ( pageStore ) {
|
||||
pageStore.toggleNetFilteringSwitch(request.url, request.scope, request.state);
|
||||
µb.updateBadgeAsync(request.tabId);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -912,6 +911,7 @@ var restoreUserData = function(userData) {
|
||||
|
||||
var onAllRemoved = function() {
|
||||
// Be sure to adjust `countdown` if adding/removing anything below
|
||||
µb.XAL.keyvalSetOne('version', userData.version);
|
||||
µBlock.saveLocalSettings(onCountdown);
|
||||
µb.XAL.keyvalSetMany(userData.userSettings, onCountdown);
|
||||
µb.XAL.keyvalSetOne('remoteBlacklists', userData.filterLists, onCountdown);
|
||||
|
@ -295,18 +295,7 @@ NetFilteringResultCache.prototype.init = function() {
|
||||
/******************************************************************************/
|
||||
|
||||
NetFilteringResultCache.prototype.dispose = function() {
|
||||
for ( var key in this.urls ) {
|
||||
if ( this.urls.hasOwnProperty(key) === false ) {
|
||||
continue;
|
||||
}
|
||||
this.urls[key].dispose();
|
||||
}
|
||||
this.urls = {};
|
||||
this.count = 0;
|
||||
if ( this.timer !== null ) {
|
||||
clearTimeout(this.timer);
|
||||
this.timer = null;
|
||||
}
|
||||
this.empty();
|
||||
this.boundPruneAsyncCallback = null;
|
||||
if ( netFilteringCacheJunkyard.length < netFilteringCacheJunkyardMax ) {
|
||||
netFilteringCacheJunkyard.push(this);
|
||||
@ -335,8 +324,19 @@ NetFilteringResultCache.prototype.add = function(context, result) {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
NetFilteringResultCache.prototype.fetchAll = function() {
|
||||
return this.urls;
|
||||
NetFilteringResultCache.prototype.empty = function() {
|
||||
for ( var key in this.urls ) {
|
||||
if ( this.urls.hasOwnProperty(key) === false ) {
|
||||
continue;
|
||||
}
|
||||
this.urls[key].dispose();
|
||||
}
|
||||
this.urls = {};
|
||||
this.count = 0;
|
||||
if ( this.timer !== null ) {
|
||||
clearTimeout(this.timer);
|
||||
this.timer = null;
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
@ -608,6 +608,13 @@ PageStore.prototype.getCosmeticFilteringSwitch = function() {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.toggleNetFilteringSwitch = function(url, scope, state) {
|
||||
µb.toggleNetFilteringSwitch(url, scope, state);
|
||||
this.netFilteringCache.empty();
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.filterRequest = function(context) {
|
||||
if ( this.getNetFilteringSwitch() === false ) {
|
||||
this.cacheResult(context, '');
|
||||
|
@ -66,9 +66,7 @@
|
||||
/******************************************************************************/
|
||||
|
||||
µBlock.saveUserSettings = function() {
|
||||
vAPI.storage.set(this.userSettings, function() {
|
||||
µBlock.getBytesInUse();
|
||||
});
|
||||
vAPI.storage.set(this.userSettings);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
@ -97,9 +95,7 @@
|
||||
var bin = {
|
||||
'netWhitelist': this.stringFromWhitelist(this.netWhitelist)
|
||||
};
|
||||
vAPI.storage.set(bin, function() {
|
||||
µBlock.getBytesInUse();
|
||||
});
|
||||
vAPI.storage.set(bin);
|
||||
this.netWhitelistModifyTime = Date.now();
|
||||
};
|
||||
|
||||
@ -128,7 +124,7 @@
|
||||
};
|
||||
|
||||
var bin = {
|
||||
'netWhitelist': '',
|
||||
'netWhitelist': 'behind-the-scene',
|
||||
'netExceptionList': ''
|
||||
};
|
||||
vAPI.storage.get(bin, onWhitelistLoaded);
|
||||
@ -595,18 +591,10 @@
|
||||
var µb = this;
|
||||
var fromSelfie = false;
|
||||
|
||||
// Filter lists
|
||||
// Whitelist
|
||||
var countdown = 2;
|
||||
|
||||
// Final initialization steps after all needed assets are in memory.
|
||||
// - Initialize internal state with maybe already existing tabs.
|
||||
// - Schedule next update operation.
|
||||
var doCountdown = function() {
|
||||
countdown -= 1;
|
||||
if ( countdown !== 0 ) {
|
||||
return;
|
||||
}
|
||||
var onAllReady = function() {
|
||||
// https://github.com/gorhill/uBlock/issues/426
|
||||
// Important: remove barrier to remote fetching, this was useful only
|
||||
// for launch time.
|
||||
@ -619,6 +607,29 @@
|
||||
µb.updater.restart(µb.firstUpdateAfter);
|
||||
};
|
||||
|
||||
// To bring older versions up to date
|
||||
var onVersionReady = function(bin) {
|
||||
var lastVersion = bin.version || '0.0.0.0';
|
||||
// Whitelist behind-the-scene scope by default
|
||||
if ( lastVersion.localeCompare('0.8.6.0') < 0 ) {
|
||||
µb.toggleNetFilteringSwitch('http://behind-the-scene/', 'site', false);
|
||||
}
|
||||
vAPI.storage.set({ version: vAPI.app.version });
|
||||
onAllReady();
|
||||
};
|
||||
|
||||
// Filter lists
|
||||
// Whitelist
|
||||
var countdown = 2;
|
||||
var doCountdown = function() {
|
||||
countdown -= 1;
|
||||
if ( countdown !== 0 ) {
|
||||
return;
|
||||
}
|
||||
// Last step: do whatever is necessary when version changes
|
||||
vAPI.storage.get('version', onVersionReady);
|
||||
};
|
||||
|
||||
// Filters are in memory.
|
||||
// Filter engines need PSL to be ready.
|
||||
var onFiltersReady = function() {
|
||||
@ -689,5 +700,4 @@
|
||||
this.loadUserSettings(onUserSettingsReady);
|
||||
this.loadWhitelist(onWhitelistReady);
|
||||
this.loadLocalSettings();
|
||||
this.getBytesInUse();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user