Skip to content

Commit

Permalink
Support converting an existing list to enabled-by-default
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Mar 17, 2022
1 parent 4c2bfbe commit 6fcc278
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/js/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -434,7 +439,7 @@ const saveAssetSourceRegistry = (( ) => {
};
})();

const updateAssetSourceRegistry = function(json, silent) {
const updateAssetSourceRegistry = function(json, silent = false) {
let newDict;
try {
newDict = JSON.parse(json);
Expand Down

0 comments on commit 6fcc278

Please sign in to comment.