aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgorhill <rhill@raymondhill.net>2015-08-18 13:15:58 -0400
committergorhill <rhill@raymondhill.net>2015-08-18 13:15:58 -0400
commitefccaf141660c5173269c5432774b7e1dd4032ea (patch)
tree7480826366741d3b7047e0718d6f582a0a75a204 /src
parent9b4b998364390290322138b898c255b0b5b2eabf (diff)
downloaduBlock-efccaf141660c5173269c5432774b7e1dd4032ea.zip
uBlock-efccaf141660c5173269c5432774b7e1dd4032ea.tar.gz
uBlock-efccaf141660c5173269c5432774b7e1dd4032ea.tar.bz2
All third-party assets which are not enabled by default will no longer be
part of the package. The code here is to ensure a seamless transition from local assets which have been converted to remote assets. The only side effect to expect is that the selfie, if any, will be invalidated.
Diffstat (limited to 'src')
-rw-r--r--src/js/assets.js39
-rw-r--r--src/js/background.js48
-rw-r--r--src/js/dynamic-net-filtering.js1
-rw-r--r--src/js/storage.js93
4 files changed, 170 insertions, 11 deletions
diff --git a/src/js/assets.js b/src/js/assets.js
index 51ba53f..b61d6c7 100644
--- a/src/js/assets.js
+++ b/src/js/assets.js
@@ -1,6 +1,6 @@
/*******************************************************************************
- µBlock - a browser extension to block requests.
+ uBlock - a browser extension to block requests.
Copyright (C) 2014-2015 Raymond Hill
This program is free software: you can redistribute it and/or modify
@@ -392,8 +392,14 @@ var getRepoMetadata = function(callback) {
continue;
}
entry = entries[path];
- // If repo checksums could not be fetched, assume no change
- if ( repoChecksums === '' ) {
+ // If repo checksums could not be fetched, assume no change.
+ // https://github.com/gorhill/uBlock/issues/602
+ // Added: if repo checksum is that of the empty string,
+ // assume no change
+ if (
+ repoChecksums === '' ||
+ entry.repoChecksum === 'd41d8cd98f00b204e9800998ecf8427e'
+ ) {
entry.repoChecksum = entry.localChecksum;
}
if ( entry.repoChecksum !== '' || entry.localChecksum === '' ) {
@@ -1042,6 +1048,33 @@ exports.rmrf = function() {
/******************************************************************************/
+exports.rename = function(from, to, callback) {
+ var done = function() {
+ if ( typeof callback === 'function' ) {
+ callback();
+ }
+ };
+
+ var fromLoaded = function(details) {
+ cachedAssetsManager.remove(from);
+ cachedAssetsManager.save(to, details.content, callback);
+ done();
+ };
+
+ var toLoaded = function(details) {
+ // `to` already exists: do nothing
+ if ( details.content !== '' ) {
+ return done();
+ }
+ cachedAssetsManager.load(from, fromLoaded);
+ };
+
+ // If `to` content already exists, do nothing.
+ cachedAssetsManager.load(to, toLoaded);
+};
+
+/******************************************************************************/
+
exports.metadata = function(callback) {
var out = {};
diff --git a/src/js/background.js b/src/js/background.js
index 402b810..b2d46b3 100644
--- a/src/js/background.js
+++ b/src/js/background.js
@@ -1,7 +1,7 @@
/*******************************************************************************
uBlock - a browser extension to block requests.
- Copyright (C) 2014 Raymond Hill
+ Copyright (C) 2014-2015 Raymond Hill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -22,12 +22,12 @@
/* global vAPI */
/* exported µBlock */
+'use strict';
+
/******************************************************************************/
var µBlock = (function() {
-'use strict';
-
/******************************************************************************/
var oneSecond = 1000;
@@ -94,7 +94,7 @@ return {
// read-only
systemSettings: {
compiledMagic: 'msgmqxreevdy',
- selfieMagic: 'spqmeuaftfra'
+ selfieMagic: 'mnigwksyvgkv'
},
restoreBackupSettings: {
@@ -139,7 +139,45 @@ return {
},
// current lists
- remoteBlacklists: {
+ remoteBlacklists: {},
+ oldListToNewListMap: {
+ "assets/thirdparties/adblock.gardar.net/is.abp.txt": "http://adblock.gardar.net/is.abp.txt",
+ "assets/thirdparties/adblock.schack.dk/block.txt": "https://adblock.schack.dk/block.txt",
+ "assets/thirdparties/dl.dropboxusercontent.com/u/1289327/abpxfiles/filtri.txt": "https://dl.dropboxusercontent.com/u/1289327/abpxfiles/filtri.txt",
+ "assets/thirdparties/easylist-downloads.adblockplus.org/advblock.txt": "https://easylist-downloads.adblockplus.org/advblock.txt",
+ "assets/thirdparties/easylist-downloads.adblockplus.org/bitblock.txt": "https://easylist-downloads.adblockplus.org/bitblock.txt",
+ "assets/thirdparties/easylist-downloads.adblockplus.org/easylist_noelemhide.txt": "https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt",
+ "assets/thirdparties/easylist-downloads.adblockplus.org/easylistchina.txt": "https://easylist-downloads.adblockplus.org/easylistchina.txt",
+ "assets/thirdparties/easylist-downloads.adblockplus.org/easylistdutch.txt": "https://easylist-downloads.adblockplus.org/easylistdutch.txt",
+ "assets/thirdparties/easylist-downloads.adblockplus.org/easylistgermany.txt": "https://easylist-downloads.adblockplus.org/easylistgermany.txt",
+ "assets/thirdparties/easylist-downloads.adblockplus.org/easylistitaly.txt": "https://easylist-downloads.adblockplus.org/easylistitaly.txt",
+ "assets/thirdparties/easylist-downloads.adblockplus.org/fanboy-annoyance.txt": "https://easylist-downloads.adblockplus.org/fanboy-annoyance.txt",
+ "assets/thirdparties/easylist-downloads.adblockplus.org/fanboy-social.txt": "https://easylist-downloads.adblockplus.org/fanboy-social.txt",
+ "assets/thirdparties/easylist-downloads.adblockplus.org/liste_fr.txt": "https://easylist-downloads.adblockplus.org/liste_fr.txt",
+ "assets/thirdparties/gitorious.org/adblock-latvian/adblock-latvian/raw/master_lists/latvian-list.txt": "https://notabug.org/latvian-list/adblock-latvian/raw/master/lists/latvian-list.txt",
+ "assets/thirdparties/home.fredfiber.no/langsholt/adblock.txt": "http://home.fredfiber.no/langsholt/adblock.txt",
+ "assets/thirdparties/hosts-file.net/ad-servers": "http://hosts-file.net/.%5Cad_servers.txt",
+ "assets/thirdparties/http://www.certyficate.it/adblock/adblock.txt": "https://www.certyficate.it/adblock/adblock.txt",
+ "assets/thirdparties/liste-ar-adblock.googlecode.com/hg/Liste_AR.txt": "https://liste-ar-adblock.googlecode.com/hg/Liste_AR.txt",
+ "assets/thirdparties/margevicius.lt/easylistlithuania.txt": "http://margevicius.lt/easylistlithuania.txt",
+ "assets/thirdparties/mirror1.malwaredomains.com/files/immortal_domains.txt": "http://malwaredomains.lehigh.edu/files/immortal_domains.txt",
+ "assets/thirdparties/raw.githubusercontent.com/AdBlockPlusIsrael/EasyListHebrew/master/EasyListHebrew.txt": "https://raw.githubusercontent.com/AdBlockPlusIsrael/EasyListHebrew/master/EasyListHebrew.txt",
+ "assets/thirdparties/raw.githubusercontent.com/cjx82630/cjxlist/master/cjxlist.txt": "https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjxlist.txt",
+ "assets/thirdparties/raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt": "https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt",
+ "assets/thirdparties/raw.githubusercontent.com/szpeter80/hufilter/master/hufilter.txt": "https://raw.githubusercontent.com/szpeter80/hufilter/master/hufilter.txt",
+ "assets/thirdparties/raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt": "https://raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt",
+ "assets/thirdparties/someonewhocares.org/hosts/hosts": "http://someonewhocares.org/hosts/hosts",
+ "assets/thirdparties/spam404bl.com/spam404scamlist.txt": "https://spam404bl.com/spam404scamlist.txt",
+ "assets/thirdparties/stanev.org/abp/adblock_bg.txt": "http://stanev.org/abp/adblock_bg.txt",
+ "assets/thirdparties/winhelp2002.mvps.org/hosts.txt": "http://winhelp2002.mvps.org/hosts.txt",
+ "assets/thirdparties/www.fanboy.co.nz/enhancedstats.txt": "https://www.fanboy.co.nz/enhancedstats.txt",
+ "assets/thirdparties/www.fanboy.co.nz/fanboy-antifacebook.txt": "https://www.fanboy.co.nz/fanboy-antifacebook.txt",
+ "assets/thirdparties/www.fanboy.co.nz/fanboy-korean.txt": "https://www.fanboy.co.nz/fanboy-korean.txt",
+ "assets/thirdparties/www.fanboy.co.nz/fanboy-swedish.txt": "https://www.fanboy.co.nz/fanboy-swedish.txt",
+ "assets/thirdparties/www.fanboy.co.nz/fanboy-ultimate.txt": "https://www.fanboy.co.nz/r/fanboy-ultimate.txt",
+ "assets/thirdparties/www.fanboy.co.nz/fanboy-vietnam.txt": "https://www.fanboy.co.nz/fanboy-vietnam.txt",
+ "assets/thirdparties/www.void.gr/kargig/void-gr-filters.txt": "https://www.void.gr/kargig/void-gr-filters.txt",
+ "assets/thirdparties/www.zoso.ro/pages/rolist.txt": ""
},
selfieAfter: 23 * oneMinute,
diff --git a/src/js/dynamic-net-filtering.js b/src/js/dynamic-net-filtering.js
index 9a1fe35..ba4039b 100644
--- a/src/js/dynamic-net-filtering.js
+++ b/src/js/dynamic-net-filtering.js
@@ -393,7 +393,6 @@ Matrix.prototype.evaluateCellZY = function(srcHostname, desHostname, type) {
}
// 3rd-party, any type
if ( this.evaluateCellZ(srcHostname, '*', '3p') !== 0 ) { return this; }
-
} else if ( type === 'script' ) {
// 1st party, specific type
if ( this.evaluateCellZ(srcHostname, '*', '1p-script') !== 0 ) { return this; }
diff --git a/src/js/storage.js b/src/js/storage.js
index 173c11d..3339b18 100644
--- a/src/js/storage.js
+++ b/src/js/storage.js
@@ -147,7 +147,7 @@
// https://github.com/gorhill/uBlock/issues/63
// Get built-in block lists: this will help us determine whether a
// specific list must be included in the result.
- this.assets.get('assets/ublock/filter-lists.json', onBuiltinListsLoaded);
+ this.loadAndPatchStockFilterLists(onBuiltinListsLoaded);
};
/******************************************************************************/
@@ -327,7 +327,7 @@
}
// get built-in block lists.
- this.assets.get('assets/ublock/filter-lists.json', onBuiltinListsLoaded);
+ this.loadAndPatchStockFilterLists(onBuiltinListsLoaded);
};
/******************************************************************************/
@@ -899,3 +899,92 @@
return handler;
})();
+
+/******************************************************************************/
+
+// https://github.com/gorhill/uBlock/issues/602
+// - Load and patch `filter-list.json`
+// - Load and patch user's `remoteBlacklists`
+// - Load and patch cached filter lists
+// - Load and patch compiled filter lists
+//
+// Once enough time has passed to safely assume all uBlock Origin
+// installations have been converted to the new stock filter lists, this code
+// can be removed.
+
+µBlock.patchFilterLists = function(filterLists) {
+ var modified = false;
+ var oldListKey, newListKey, listEntry;
+ for ( var listKey in filterLists ) {
+ if ( filterLists.hasOwnProperty(listKey) === false ) {
+ continue;
+ }
+ oldListKey = listKey;
+ if ( this.oldListToNewListMap.hasOwnProperty(oldListKey) === false ) {
+ oldListKey = 'assets/thirdparties/' + listKey;
+ if ( this.oldListToNewListMap.hasOwnProperty(oldListKey) === false ) {
+ continue;
+ }
+ }
+ newListKey = this.oldListToNewListMap[oldListKey];
+ if ( newListKey !== '' ) {
+ listEntry = filterLists[listKey];
+ listEntry.homeURL = undefined;
+ filterLists[newListKey] = listEntry;
+ }
+ delete filterLists[listKey];
+ modified = true;
+ }
+ return modified;
+};
+
+µBlock.loadAndPatchStockFilterLists = function(callback) {
+ var onStockListsLoaded = function(details) {
+ var µb = µBlock;
+ var stockLists;
+ try {
+ stockLists = JSON.parse(details.content);
+ } catch (e) {
+ stockLists = {};
+ }
+
+ // Migrate assets affected by the change to their new name.
+ var newListKey;
+ for ( var oldListKey in stockLists ) {
+ if ( stockLists.hasOwnProperty(oldListKey) === false ) {
+ continue;
+ }
+ oldListKey = 'assets/thirdparties/' + oldListKey;
+ if ( µb.oldListToNewListMap.hasOwnProperty(oldListKey) === false ) {
+ continue;
+ }
+ newListKey = µb.oldListToNewListMap[oldListKey];
+ // Remove cached and compiled list
+ if ( newListKey === '' ) {
+ continue;
+ }
+ // Rename cached and compiled list (important: compiled list first)
+ µb.assets.rename(µb.getCompiledFilterListPath(oldListKey),
+ µb.getCompiledFilterListPath(newListKey));
+ µb.assets.rename(oldListKey, newListKey);
+ }
+ µb.patchFilterLists(stockLists);
+
+ // Stock lists information cascades into
+ // - In-memory user's selected filter lists, so we need to patch this.
+ µb.patchFilterLists(µb.remoteBlacklists);
+
+ // Stock lists information cascades into
+ // - In-storage user's selected filter lists, so we need to patch this.
+ vAPI.storage.get('remoteBlacklists', function(bin) {
+ var userLists = bin.remoteBlacklists || {};
+ if ( µb.patchFilterLists(userLists) ) {
+ µb.keyvalSetOne('remoteBlacklists', userLists);
+ }
+ details.content = JSON.stringify(stockLists);
+ callback(details);
+ });
+ };
+
+ this.assets.get('assets/ublock/filter-lists.json', onStockListsLoaded);
+};