|
|
@ -158,7 +158,7 @@
|
|
|
|
this.rawSettings.suspendTabsUntilReady ? 'yes' : 'unset';
|
|
|
|
this.rawSettings.suspendTabsUntilReady ? 'yes' : 'unset';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.fireDOMEvent('hiddenSettingsChanged');
|
|
|
|
this.fireDOMEvent('rawSettingsChanged');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Note: Save only the settings which values differ from the default ones.
|
|
|
|
// Note: Save only the settings which values differ from the default ones.
|
|
|
@ -175,11 +175,11 @@
|
|
|
|
bin.rawSettings[prop] = this.rawSettings[prop];
|
|
|
|
bin.rawSettings[prop] = this.rawSettings[prop];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
vAPI.storage.set(bin);
|
|
|
|
|
|
|
|
this.saveImmediateHiddenSettings();
|
|
|
|
this.saveImmediateHiddenSettings();
|
|
|
|
|
|
|
|
return vAPI.storage.set(bin);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
self.addEventListener('hiddenSettingsChanged', ( ) => {
|
|
|
|
self.addEventListener('rawSettingsChanged', ( ) => {
|
|
|
|
const µm = µMatrix;
|
|
|
|
const µm = µMatrix;
|
|
|
|
self.log.verbosity = µm.rawSettings.consoleLogLevel;
|
|
|
|
self.log.verbosity = µm.rawSettings.consoleLogLevel;
|
|
|
|
vAPI.net.setOptions({
|
|
|
|
vAPI.net.setOptions({
|
|
|
@ -192,113 +192,56 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// These settings must be available immediately on startup, without delay
|
|
|
|
self.addEventListener('rawSettingsChanged', ( ) => {
|
|
|
|
// through the vAPI.localStorage. Add/remove settings as needed.
|
|
|
|
const µm = µMatrix;
|
|
|
|
|
|
|
|
self.log.verbosity = µm.rawSettings.consoleLogLevel;
|
|
|
|
µMatrix.saveImmediateHiddenSettings = function() {
|
|
|
|
vAPI.net.setOptions({
|
|
|
|
const props = [
|
|
|
|
cnameIgnoreList: µm.rawSettings.cnameIgnoreList,
|
|
|
|
'consoleLogLevel',
|
|
|
|
cnameIgnore1stParty: µm.rawSettings.cnameIgnore1stParty,
|
|
|
|
'disableWebAssembly',
|
|
|
|
cnameIgnoreExceptions: µm.rawSettings.cnameIgnoreExceptions,
|
|
|
|
'suspendTabsUntilReady',
|
|
|
|
cnameIgnoreRootDocument: µm.rawSettings.cnameIgnoreRootDocument,
|
|
|
|
];
|
|
|
|
cnameMaxTTL: µm.rawSettings.cnameMaxTTL,
|
|
|
|
const toSave = {};
|
|
|
|
cnameReplayFullURL: µm.rawSettings.cnameReplayFullURL,
|
|
|
|
for ( const prop of props ) {
|
|
|
|
});
|
|
|
|
if ( this.rawSettings[prop] !== this.rawSettingsDefault[prop] ) {
|
|
|
|
});
|
|
|
|
toSave[prop] = this.rawSettings[prop];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( Object.keys(toSave).length !== 0 ) {
|
|
|
|
|
|
|
|
vAPI.localStorage.setItem(
|
|
|
|
|
|
|
|
'immediateHiddenSettings',
|
|
|
|
|
|
|
|
JSON.stringify(toSave)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
vAPI.localStorage.removeItem('immediateHiddenSettings');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
µMatrix.loadRawSettings = async function() {
|
|
|
|
|
|
|
|
const bin = await vAPI.storage.get('rawSettings');
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
bin instanceof Object === false ||
|
|
|
|
|
|
|
|
bin.rawSettings instanceof Object === false
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( const key of Object.keys(bin.rawSettings) ) {
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
this.rawSettings.hasOwnProperty(key) === false ||
|
|
|
|
|
|
|
|
typeof bin.rawSettings[key] !== typeof this.rawSettings[key]
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.rawSettings[key] = bin.rawSettings[key];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.rawSettingsWriteTime = Date.now();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
µMatrix.saveRawSettings = async function(rawSettings) {
|
|
|
|
|
|
|
|
const keys = Object.keys(rawSettings);
|
|
|
|
|
|
|
|
if ( keys.length === 0 ) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( const key of keys ) {
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
this.rawSettingsDefault.hasOwnProperty(key) &&
|
|
|
|
|
|
|
|
typeof rawSettings[key] === typeof this.rawSettingsDefault[key]
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
this.rawSettings[key] = rawSettings[key];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.saveImmediateHiddenSettings();
|
|
|
|
|
|
|
|
this.rawSettingsWriteTime = Date.now();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await vAPI.storage.set({ rawSettings: this.rawSettings });
|
|
|
|
/******************************************************************************/
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
µMatrix.rawSettingsFromString = function(raw) {
|
|
|
|
µMatrix.rawSettingsFromString = function(raw) {
|
|
|
|
const result = {};
|
|
|
|
const out = Object.assign({}, this.rawSettingsDefault);
|
|
|
|
const lineIter = new this.LineIterator(raw);
|
|
|
|
const lineIter = new this.LineIterator(raw);
|
|
|
|
while ( lineIter.eot() === false ) {
|
|
|
|
while ( lineIter.eot() === false ) {
|
|
|
|
const line = lineIter.next().trim();
|
|
|
|
const line = lineIter.next();
|
|
|
|
const matches = /^(\S+)(\s+(.+))?$/.exec(line);
|
|
|
|
const matches = /^\s*(\S+)\s+(.+)$/.exec(line);
|
|
|
|
if ( matches === null ) { continue; }
|
|
|
|
if ( matches === null || matches.length !== 3 ) { continue; }
|
|
|
|
const name = matches[1];
|
|
|
|
const name = matches[1];
|
|
|
|
if ( this.rawSettingsDefault.hasOwnProperty(name) === false ) {
|
|
|
|
if ( out.hasOwnProperty(name) === false ) { continue; }
|
|
|
|
continue;
|
|
|
|
const value = matches[2].trim();
|
|
|
|
}
|
|
|
|
switch ( typeof out[name] ) {
|
|
|
|
let value = (matches[2] || '').trim();
|
|
|
|
|
|
|
|
switch ( typeof this.rawSettingsDefault[name] ) {
|
|
|
|
|
|
|
|
case 'boolean':
|
|
|
|
case 'boolean':
|
|
|
|
if ( value === 'true' ) {
|
|
|
|
if ( value === 'true' ) {
|
|
|
|
value = true;
|
|
|
|
out[name] = true;
|
|
|
|
} else if ( value === 'false' ) {
|
|
|
|
} else if ( value === 'false' ) {
|
|
|
|
value = false;
|
|
|
|
out[name] = false;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
value = this.rawSettingsDefault[name];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'string':
|
|
|
|
case 'string':
|
|
|
|
if ( value === '' ) {
|
|
|
|
out[name] = value;
|
|
|
|
value = this.rawSettingsDefault[name];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'number':
|
|
|
|
case 'number': {
|
|
|
|
value = parseInt(value, 10);
|
|
|
|
const i = parseInt(value, 10);
|
|
|
|
if ( isNaN(value) ) {
|
|
|
|
if ( isNaN(i) === false ) {
|
|
|
|
value = this.rawSettingsDefault[name];
|
|
|
|
out[name] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( this.rawSettings[name] !== value ) {
|
|
|
|
|
|
|
|
result[name] = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.saveRawSettings(result);
|
|
|
|
this.rawSettings = out;
|
|
|
|
|
|
|
|
this.saveRawSettings();
|
|
|
|
|
|
|
|
this.fireDOMEvent('rawSettingsChanged');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
µMatrix.stringFromRawSettings = function() {
|
|
|
|
µMatrix.stringFromRawSettings = function() {
|
|
|
@ -309,16 +252,30 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
|
|
|
|
return out.join('\n');
|
|
|
|
return out.join('\n');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
// These settings must be available immediately on startup, without delay
|
|
|
|
// These settings must be available immediately on startup, without delay
|
|
|
|
// through the vAPI.localStorage. Add/remove settings as needed.
|
|
|
|
// through the vAPI.localStorage. Add/remove settings as needed.
|
|
|
|
|
|
|
|
|
|
|
|
µMatrix.saveImmediateHiddenSettings = function() {
|
|
|
|
µMatrix.saveImmediateHiddenSettings = function() {
|
|
|
|
vAPI.localStorage.setItem(
|
|
|
|
const props = [
|
|
|
|
'immediateRawSettings',
|
|
|
|
'consoleLogLevel',
|
|
|
|
JSON.stringify({
|
|
|
|
'suspendTabsUntilReady',
|
|
|
|
suspendTabsUntilReady: this.rawSettings.suspendTabsUntilReady,
|
|
|
|
];
|
|
|
|
})
|
|
|
|
const toSave = {};
|
|
|
|
);
|
|
|
|
for ( const prop of props ) {
|
|
|
|
|
|
|
|
if ( this.rawSettings[prop] !== this.rawSettingsDefault[prop] ) {
|
|
|
|
|
|
|
|
toSave[prop] = this.rawSettings[prop];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( Object.keys(toSave).length !== 0 ) {
|
|
|
|
|
|
|
|
vAPI.localStorage.setItem(
|
|
|
|
|
|
|
|
'immediateHiddenSettings',
|
|
|
|
|
|
|
|
JSON.stringify(toSave)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
vAPI.localStorage.removeItem('immediateHiddenSettings');
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
@ -816,6 +773,7 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
µm.ubiquitousBlacklistRef =
|
|
|
|
µm.ubiquitousBlacklistRef =
|
|
|
|
µm.ubiquitousBlacklist.createOne(bin.hostsFilesSelfie.trieref);
|
|
|
|
µm.ubiquitousBlacklist.createOne(bin.hostsFilesSelfie.trieref);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
cancel: function() {
|
|
|
|
cancel: function() {
|
|
|
|
if ( timer !== undefined ) {
|
|
|
|
if ( timer !== undefined ) {
|
|
|
@ -832,10 +790,6 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
|
|
|
|
// TODO: remove once all users are way past 1.4.0.
|
|
|
|
// TODO: remove once all users are way past 1.4.0.
|
|
|
|
this.cacheStorage.remove('publicSuffixListSelfie');
|
|
|
|
this.cacheStorage.remove('publicSuffixListSelfie');
|
|
|
|
|
|
|
|
|
|
|
|
if ( this.rawSettings.disableWebAssembly === false ) {
|
|
|
|
|
|
|
|
publicSuffixList.enableWASM();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const result = await this.assets.get(`compiled/${this.pslAssetKey}`);
|
|
|
|
const result = await this.assets.get(`compiled/${this.pslAssetKey}`);
|
|
|
|
if ( publicSuffixList.fromSelfie(result.content, this.base64) ) {
|
|
|
|
if ( publicSuffixList.fromSelfie(result.content, this.base64) ) {
|
|
|
|