1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

Support converting an existing list to enabled-by-default

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2056
This commit is contained in:
Raymond Hill 2022-03-17 14:04:09 -04:00
parent 4c2bfbe543
commit 6fcc278c59
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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);