From 6fcc278c59f2921ae668528253d1bf5fa52697c8 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 17 Mar 2022 14:04:09 -0400 Subject: [PATCH] Support converting an existing list to enabled-by-default Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2056 --- src/js/assets.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/js/assets.js b/src/js/assets.js index fa327d52f..b8fd7cb5c 100644 --- a/src/js/assets.js +++ b/src/js/assets.js @@ -343,8 +343,8 @@ assets.fetchFilterList = async function(mainlistURL) { **/ -let assetSourceRegistryPromise, - assetSourceRegistry = Object.create(null); +let assetSourceRegistryPromise; +let assetSourceRegistry = Object.create(null); const getAssetSourceRegistry = function() { if ( assetSourceRegistryPromise === undefined ) { @@ -376,6 +376,11 @@ const getAssetSourceRegistry = function() { const registerAssetSource = function(assetKey, dict) { const entry = assetSourceRegistry[assetKey] || {}; + // https://github.com/uBlockOrigin/uBlock-issues/issues/2056 + // An existing list may become enabled by default + if ( dict.off === undefined && entry.off === true ) { + delete entry.off; + } for ( const prop in dict ) { if ( dict.hasOwnProperty(prop) === false ) { continue; } if ( dict[prop] === undefined ) { @@ -434,7 +439,7 @@ const saveAssetSourceRegistry = (( ) => { }; })(); -const updateAssetSourceRegistry = function(json, silent) { +const updateAssetSourceRegistry = function(json, silent = false) { let newDict; try { newDict = JSON.parse(json);