diff --git a/assets/assets.json b/assets/assets.json index fff3902ad..d7f137827 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -16,6 +16,14 @@ "assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat" ] }, + "ublock-badlists": { + "content": "internal", + "updateAfter": 13, + "contentURL": [ + "https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/badlists.txt", + "assets/ublock/badlists.txt" + ] + }, "ublock-filters": { "content": "filters", "group": "default", diff --git a/src/js/background.js b/src/js/background.js index 158bad813..73a0bcb6d 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -171,6 +171,7 @@ const µBlock = (( ) => { // jshint ignore:line selectedFilterLists: [], availableFilterLists: {}, + badLists: new Set(), // https://github.com/uBlockOrigin/uBlock-issues/issues/974 // This can be used to defer filtering decision-making. diff --git a/src/js/storage.js b/src/js/storage.js index c47db98ab..a13e47930 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -481,6 +481,15 @@ self.addEventListener('hiddenSettingsChanged', ( ) => { let oldAvailableLists = {}, newAvailableLists = {}; + if ( this.badLists.size === 0 ) { + const details = await this.assets.get('ublock-badlists'); + this.badLists = new Set( + details.content.split(/\s*[\n\r]+\s*/).filter(a => { + return a !== '' && a.startsWith('#') === false; + }) + ); + } + // User filter list. newAvailableLists[this.userFiltersPath] = { group: 'user', @@ -498,7 +507,7 @@ self.addEventListener('hiddenSettingsChanged', ( ) => { external: true, group: 'custom', submitter: 'user', - title: '' + title: '', }; newAvailableLists[listKey] = entry; this.assets.registerAssetSource(listKey, entry); @@ -705,7 +714,10 @@ self.addEventListener('hiddenSettingsChanged', ( ) => { µBlock.getCompiledFilterList = async function(assetKey) { const compiledPath = 'compiled/' + assetKey; - if ( this.compiledFormatChanged === false ) { + if ( + this.compiledFormatChanged === false && + this.badLists.has(assetKey) === false + ) { let compiledDetails = await this.assets.get(compiledPath); if ( compiledDetails.content !== '' ) { compiledDetails.assetKey = assetKey; @@ -722,6 +734,11 @@ self.addEventListener('hiddenSettingsChanged', ( ) => { this.extractFilterListMetadata(assetKey, rawDetails.content); + // Skip compiling bad lists. + if ( this.badLists.has(assetKey) ) { + return { assetKey, content: '' }; + } + // Fetching the raw content may cause the compiled content to be // generated somewhere else in uBO, hence we try one last time to // fetch the compiled content in case it has become available. @@ -1339,13 +1356,15 @@ self.addEventListener('hiddenSettingsChanged', ( ) => { details.assetKey, details.content ); - this.assets.put( - 'compiled/' + details.assetKey, - this.compileFilters( - details.content, - { assetKey: details.assetKey } - ) - ); + if ( this.badLists.has(details.assetKey) === false ) { + this.assets.put( + 'compiled/' + details.assetKey, + this.compileFilters( + details.content, + { assetKey: details.assetKey } + ) + ); + } } } else { this.removeCompiledFilterList(details.assetKey); @@ -1354,6 +1373,8 @@ self.addEventListener('hiddenSettingsChanged', ( ) => { if ( cached ) { this.compilePublicSuffixList(details.content); } + } else if ( details.assetKey === 'ublock-badlists' ) { + this.badLists = new Set(); } vAPI.messaging.broadcast({ what: 'assetUpdated',