mirror of https://github.com/gorhill/uBlock.git
code review re. 3628de7a9d
This commit is contained in:
parent
b55447635e
commit
50889da226
|
@ -63,6 +63,7 @@ var lastRepoMetaIsRemote = false;
|
|||
var refreshRepoMetaPeriod = 5 * oneHour;
|
||||
var errorCantConnectTo = vAPI.i18n('errorCantConnectTo');
|
||||
var xhrTimeout = vAPI.localStorage.getItem('xhrTimeout') || 30000;
|
||||
var onAssetRemovedListener = null;
|
||||
|
||||
var exports = {
|
||||
autoUpdate: true,
|
||||
|
@ -210,8 +211,8 @@ var cachedAssetsManager = (function() {
|
|||
}
|
||||
// Saving over an existing item must be seen as removing an
|
||||
// existing item and adding a new one.
|
||||
if ( typeof exports.onRemovedListener === 'function' ) {
|
||||
exports.onRemovedListener(removedItems);
|
||||
if ( onAssetRemovedListener instanceof Function ) {
|
||||
onAssetRemovedListener(removedItems);
|
||||
}
|
||||
cbSuccess(details);
|
||||
};
|
||||
|
@ -251,8 +252,8 @@ var cachedAssetsManager = (function() {
|
|||
if ( keystoRemove.length ) {
|
||||
vAPI.cacheStorage.remove(keystoRemove);
|
||||
vAPI.cacheStorage.set({ 'cached_asset_entries': entries });
|
||||
if ( typeof exports.onRemovedListener === 'function' ) {
|
||||
exports.onRemovedListener(removedItems);
|
||||
if ( onAssetRemovedListener instanceof Function ) {
|
||||
onAssetRemovedListener(removedItems);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -281,8 +282,6 @@ var cachedAssetsManager = (function() {
|
|||
return entries !== null && entries.hasOwnProperty(path);
|
||||
};
|
||||
|
||||
exports.onRemovedListener = null;
|
||||
|
||||
getEntries(function(){});
|
||||
|
||||
return exports;
|
||||
|
@ -1046,12 +1045,16 @@ var readUserAsset = function(path, callback) {
|
|||
var saveUserAsset = function(path, content, callback) {
|
||||
var bin = {};
|
||||
bin[path] = content;
|
||||
var onSaved;
|
||||
if ( callback instanceof Function ) {
|
||||
onSaved = function() {
|
||||
var onSaved = function() {
|
||||
// Saving over an existing asset must be seen as removing an
|
||||
// existing asset and adding a new one.
|
||||
if ( onAssetRemovedListener instanceof Function ) {
|
||||
onAssetRemovedListener([ path ]);
|
||||
}
|
||||
if ( callback instanceof Function ) {
|
||||
callback({ path: path, content: content });
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
vAPI.storage.set(bin, onSaved);
|
||||
};
|
||||
|
||||
|
@ -1292,9 +1295,9 @@ exports.purgeAll = function(callback) {
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
exports.onAssetCacheRemoved = {
|
||||
addEventListener: function(callback) {
|
||||
cachedAssetsManager.onRemovedListener = callback || null;
|
||||
exports.onAssetRemoved = {
|
||||
addListener: function(callback) {
|
||||
onAssetRemovedListener = callback instanceof Function ? callback : null;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ var onAllReady = function() {
|
|||
µb.assetUpdater.onStart.addEventListener(µb.updateStartHandler.bind(µb));
|
||||
µb.assetUpdater.onCompleted.addEventListener(µb.updateCompleteHandler.bind(µb));
|
||||
µb.assetUpdater.onAssetUpdated.addEventListener(µb.assetUpdatedHandler.bind(µb));
|
||||
µb.assets.onAssetCacheRemoved.addEventListener(µb.assetCacheRemovedHandler.bind(µb));
|
||||
µb.assets.onAssetRemoved.addListener(µb.assetCacheRemovedHandler.bind(µb));
|
||||
|
||||
// Important: remove barrier to remote fetching, this was useful only
|
||||
// for launch time.
|
||||
|
@ -98,24 +98,17 @@ var onPSLReady = function() {
|
|||
// To bring older versions up to date
|
||||
|
||||
var onVersionReady = function(lastVersion) {
|
||||
// Whitelist some key scopes by default
|
||||
if ( lastVersion.localeCompare('0.8.6.0') < 0 ) {
|
||||
µb.netWhitelist = µb.whitelistFromString(
|
||||
µb.stringFromWhitelist(µb.netWhitelist) +
|
||||
'\n' +
|
||||
µb.netWhitelistDefault
|
||||
);
|
||||
µb.saveWhitelist();
|
||||
}
|
||||
// https://github.com/gorhill/uBlock/issues/135#issuecomment-96677379
|
||||
// `about:loopconversation` is used by Firefox for its Hello service
|
||||
if ( lastVersion.localeCompare('0.9.5.2') < 0 ) {
|
||||
µb.netWhitelist = µb.whitelistFromString(
|
||||
µb.stringFromWhitelist(µb.netWhitelist) +
|
||||
'\n' +
|
||||
'loopconversation.about-scheme'
|
||||
);
|
||||
µb.saveWhitelist();
|
||||
// After 1.9.16, non-advanced users can have access to the dynamic
|
||||
// filtering pane in read-only mode. Still, it should not be visible by
|
||||
// default.
|
||||
if ( lastVersion.localeCompare('1.9.18') < 0 ) {
|
||||
if (
|
||||
µb.userSettings.advancedUserEnabled === false &&
|
||||
µb.userSettings.dynamicFilteringEnabled === true
|
||||
) {
|
||||
µb.userSettings.dynamicFilteringEnabled = false;
|
||||
µb.keyvalSetOne('dynamicFilteringEnabled', false);
|
||||
}
|
||||
}
|
||||
if ( lastVersion !== vAPI.app.version ) {
|
||||
vAPI.storage.set({ version: vAPI.app.version });
|
||||
|
|
Loading…
Reference in New Issue