mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-02 00:42:45 +01:00
code review: fixed reloading of dynamic filtering rules
This commit is contained in:
parent
2e57a37e56
commit
f36880315a
@ -430,7 +430,11 @@ Matrix.prototype.fromObsoleteSelfie = function(selfie) {
|
||||
if ( selfie === '' ) {
|
||||
return '';
|
||||
}
|
||||
var bin = JSON.parse(selfie);
|
||||
var bin = {};
|
||||
try {
|
||||
bin = JSON.parse(selfie);
|
||||
} catch(e) {
|
||||
}
|
||||
var filters = bin.filters;
|
||||
var bits, val;
|
||||
for ( var hostname in filters ) {
|
||||
|
@ -77,7 +77,7 @@
|
||||
var settingsLoaded = function(store) {
|
||||
µBlock.userSettings = store;
|
||||
if ( typeof callback === 'function' ) {
|
||||
callback(store);
|
||||
callback(µBlock.userSettings);
|
||||
}
|
||||
};
|
||||
|
||||
@ -651,31 +651,32 @@
|
||||
};
|
||||
|
||||
// User settings are in memory
|
||||
var onUserSettingsReady = function(settings) {
|
||||
var onUserSettingsReady = function(userSettings) {
|
||||
// https://github.com/gorhill/uBlock/issues/426
|
||||
// Important: block remote fetching for when loading assets at launch
|
||||
// time.
|
||||
µb.assets.allowRemoteFetch = false;
|
||||
µb.assets.autoUpdate = settings.autoUpdate;
|
||||
µb.assets.autoUpdate = userSettings.autoUpdate;
|
||||
µb.fromSelfie(onSelfieReady);
|
||||
µb.mirrors.toggle(settings.experimentalEnabled);
|
||||
µb.contextMenu.toggle(settings.contextMenuEnabled);
|
||||
µb.mirrors.toggle(userSettings.experimentalEnabled);
|
||||
µb.contextMenu.toggle(userSettings.contextMenuEnabled);
|
||||
µb.dynamicNetFilteringEngine.fromString(userSettings.dynamicFilteringString);
|
||||
|
||||
// Remove obsolete setting
|
||||
delete µb.userSettings.logRequests;
|
||||
delete userSettings.logRequests;
|
||||
µb.XAL.keyvalRemoveOne('logRequests');
|
||||
|
||||
if ( typeof settings.dynamicFilteringSelfie === 'string' ) {
|
||||
if ( settings.dynamicFilteringString === '' && settings.dynamicFilteringSelfie !== '' ) {
|
||||
µb.dynamicNetFilteringEngine.fromObsoleteSelfie(settings.dynamicFilteringSelfie);
|
||||
µb.userSettings.dynamicFilteringString = µb.dynamicNetFilteringEngine.toString();
|
||||
µb.XAL.keyvalSetOne('dynamicFilteringString', µb.userSettings.dynamicFilteringString);
|
||||
if ( typeof userSettings.dynamicFilteringSelfie === 'string' ) {
|
||||
if ( userSettings.dynamicFilteringString === '' && userSettings.dynamicFilteringSelfie !== '' ) {
|
||||
µb.dynamicNetFilteringEngine.fromObsoleteSelfie(userSettings.dynamicFilteringSelfie);
|
||||
userSettings.dynamicFilteringString = µb.dynamicNetFilteringEngine.toString();
|
||||
µb.XAL.keyvalSetOne('dynamicFilteringString', userSettings.dynamicFilteringString);
|
||||
|
||||
// Auto-enable advanced user if there were dynamic rules
|
||||
µb.userSettings.advancedUserEnabled = true;
|
||||
µb.XAL.keyvalSetOne('advancedUserEnabled', true);
|
||||
userSettings.advancedUserEnabled = userSettings.dynamicFilteringString !== '';
|
||||
µb.XAL.keyvalSetOne('advancedUserEnabled', userSettings.advancedUserEnabled);
|
||||
}
|
||||
delete µb.userSettings.dynamicFilteringSelfie;
|
||||
delete userSettings.dynamicFilteringSelfie;
|
||||
µb.XAL.keyvalRemoveOne('dynamicFilteringSelfie');
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user