diff --git a/assets/ublock/filter-lists.json b/assets/ublock/filter-lists.json index 4ded92154..6d294a3bc 100644 --- a/assets/ublock/filter-lists.json +++ b/assets/ublock/filter-lists.json @@ -1,221 +1,267 @@ { "easylist-downloads.adblockplus.org/easylist.txt": { "title": "EasyList", - "group": "ads" + "group": "ads", + "homeURL": "https://easylist-downloads.adblockplus.org/easylist.txt" }, "easylist-downloads.adblockplus.org/easyprivacy.txt": { "title": "EasyPrivacy", - "group": "privacy" + "group": "privacy", + "homeURL": "https://easylist-downloads.adblockplus.org/easyprivacy.txt" }, "mirror1.malwaredomains.com/files/immortal_domains.txt": { "title": "Malware domains (long-lived)", - "group": "malware" + "group": "malware", + "homeURL": "http://mirror1.malwaredomains.com/files/immortal_domains.txt" }, "mirror1.malwaredomains.com/files/justdomains": { "title": "Malware domains", - "group": "malware" + "group": "malware", + "homeURL": "http://mirror1.malwaredomains.com/files/justdomains" }, "pgl.yoyo.org/as/serverlist": { "title": "Peter Lowe’s Ad server list", - "group": "ads" + "group": "ads", + "homeURL": "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext" }, "www.malwaredomainlist.com/hostslist/hosts.txt": { "title": "Malware Domain List", - "group": "malware" + "group": "malware", + "homeURL": "http://www.malwaredomainlist.com/hostslist/hosts.txt" }, "hosts-file.net/ad-servers": { "off": true, "title": "hpHosts’s Ad and tracking servers", - "group": "multipurpose" + "group": "multipurpose", + "homeURL": "http://hosts-file.net/.%5Cad_servers.txt" }, "easylist-downloads.adblockplus.org/easylist_noelemhide.txt": { "off": true, "title": "EasyList without element hiding rules", - "group": "ads" + "group": "ads", + "homeURL": "https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt" }, "www.fanboy.co.nz/enhancedstats.txt": { "off": true, "title": "Fanboy’s Enhanced Tracking List", - "group": "privacy" + "group": "privacy", + "homeURL": "https://www.fanboy.co.nz/enhancedstats.txt" }, "easylist-downloads.adblockplus.org/fanboy-annoyance.txt": { "off": true, "title": "Fanboy’s Annoyance List", - "group": "social" + "group": "social", + "homeURL": "https://easylist-downloads.adblockplus.org/fanboy-annoyance.txt" }, "easylist-downloads.adblockplus.org/fanboy-social.txt": { "off": true, "title": "Fanboy’s Social Blocking List", - "group": "social" + "group": "social", + "homeURL": "https://easylist-downloads.adblockplus.org/fanboy-social.txt" }, "www.fanboy.co.nz/fanboy-antifacebook.txt": { "off": true, "title": "Fanboy’s Anti-Facebook (see warning inside list)", - "group": "social" + "group": "social", + "homeURL": "https://www.fanboy.co.nz/fanboy-antifacebook.txt" }, "raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt": { "off": true, "title": "Anti-Adblock Killer | Filters for Adblockers", - "group": "ads" + "group": "ads", + "homeURL": "https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt" }, "www.fanboy.co.nz/fanboy-ultimate.txt": { "off": true, "title": "Fanboy+Easylist-Merged Ultimate List", - "group": "multipurpose" + "group": "multipurpose", + "homeURL": "https://www.fanboy.co.nz/r/fanboy-ultimate.txt" }, "someonewhocares.org/hosts/hosts": { "off": true, "title": "Dan Pollock’s hosts file", - "group": "multipurpose" + "group": "multipurpose", + "homeURL": "http://someonewhocares.org/hosts/hosts" }, "winhelp2002.mvps.org/hosts.txt": { "off": true, "title": "MVPS HOSTS", - "group": "multipurpose" + "group": "multipurpose", + "homeURL": "http://winhelp2002.mvps.org/hosts.txt" }, "spam404bl.com/spam404scamlist.txt": { "off": true, "title": "Spam404", - "group": "malware" + "group": "malware", + "homeURL": "http://spam404bl.com/spam404scamlist.txt" }, "easylist-downloads.adblockplus.org/easylistgermany.txt": { "off": true, "title": "DEU: EasyList Germany", - "group": "regions" + "group": "regions", + "homeURL": "https://easylist-downloads.adblockplus.org/easylistgermany.txt" }, "easylist-downloads.adblockplus.org/easylistitaly.txt": { "off": true, "title": "ITA: EasyList Italy", - "group": "regions" + "group": "regions", + "homeURL": "https://easylist-downloads.adblockplus.org/easylistitaly.txt" }, "easylist-downloads.adblockplus.org/easylistdutch.txt": { "off": true, "title": "NLD: EasyList Dutch", - "group": "regions" + "group": "regions", + "homeURL": "https://easylist-downloads.adblockplus.org/easylistdutch.txt" }, "easylist-downloads.adblockplus.org/liste_fr.txt": { "off": true, "title": "FRA: EasyList Liste FR", - "group": "regions" + "group": "regions", + "homeURL": "https://easylist-downloads.adblockplus.org/liste_fr.txt" }, "easylist-downloads.adblockplus.org/advblock.txt": { "off": true, "title": "RUS: RU AdList (Дополнительная региональная подписка)", - "group": "regions" + "group": "regions", + "homeURL": "https://easylist-downloads.adblockplus.org/advblock.txt" }, "easylist-downloads.adblockplus.org/bitblock.txt": { "off": true, "title": "RUS: BitBlock List (Дополнительная подписка фильтров)", - "group": "regions" + "group": "regions", + "homeURL": "https://easylist-downloads.adblockplus.org/bitblock.txt" }, "easylist-downloads.adblockplus.org/easylistchina.txt": { "off": true, "title": "CHN: EasyList China (中文)", - "group": "regions" + "group": "regions", + "homeURL": "https://easylist-downloads.adblockplus.org/easylistchina.txt" }, "cjxlist1.googlecode.com/svn/cjxlist.txt": { "off": true, "title": "CHN: China: cjxlist (main focus on Chinese sites)", - "group": "regions" + "group": "regions", + "homeURL": "https://cjxlist1.googlecode.com/svn/cjxlist.txt" }, "adblock-chinalist.googlecode.com/svn/trunk/adblock.txt": { "off": true, "title": "CHN: EasyList China (obsolete: to be removed)", - "group": "regions" + "group": "regions", + "homeURL": "http://adblock-chinalist.googlecode.com/svn/trunk/adblock.txt" }, "adblock-plus-japanese-filter.googlecode.com/hg/abp_jp.txt": { "off": true, "title": "JPN: ABP Japanese filters (の日本用フィルタ)", - "group": "regions" + "group": "regions", + "homeURL": "https://adblock-plus-japanese-filter.googlecode.com/hg/abp_jp.txt" }, - "margevicius.lt/AdBlockPlusLithuania.txt": { + "margevicius.lt/easylistlithuania.txt": { "off": true, "title": "LTU: Adblock Plus Lithuania", - "group": "regions" + "group": "regions", + "old": "margevicius.lt/AdBlockPlusLithuania.txt", + "homeURL": "http://margevicius.lt/easylistlithuania.txt" }, "stanev.org/abp/adblock_bg.txt": { "off": true, "title": "BGR: Bulgarian Adblock list", - "group": "regions" + "group": "regions", + "homeURL": "http://stanev.org/abp/adblock_bg.txt" }, "indonesianadblockrules.googlecode.com/hg/subscriptions/abpindo.txt": { "off": true, "title": "IDN: ABPindo", - "group": "regions" + "group": "regions", + "homeURL": "https://indonesianadblockrules.googlecode.com/hg/subscriptions/abpindo.txt" }, "liste-ar-adblock.googlecode.com/hg/Liste_AR.txt": { "off": true, "title": "ara: Liste AR", - "group": "regions" + "group": "regions", + "homeURL": "https://liste-ar-adblock.googlecode.com/hg/Liste_AR.txt" }, "raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt": { "off": true, "title": "CZE, SVK: EasyList Czech and Slovak", - "group": "regions" + "group": "regions", + "homeURL": "https://raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt" }, "raw.githubusercontent.com/adblockpolska/Adblock_PL_List/master/adblock_polska.txt": { "off": true, "title": "POL: Adblock Polska", - "group": "regions" + "group": "regions", + "homeURL": "https://raw.githubusercontent.com/adblockpolska/Adblock_PL_List/master/adblock_polska.txt" }, "raw.githubusercontent.com/AdBlockPlusIsrael/EasyListHebrew/master/EasyListHebrew.txt": { "off": true, "title": "ISR: EasyList Hebrew", - "group": "regions" + "group": "regions", + "homeURL": "https://raw.githubusercontent.com/AdBlockPlusIsrael/EasyListHebrew/master/EasyListHebrew.txt" }, "raw.githubusercontent.com/wiltteri/wiltteri.txt/master/wiltteri.txt": { "off": true, "title": "FIN: Wiltteri", - "group": "regions" + "group": "regions", + "homeURL": "http://raw.githubusercontent.com/wiltteri/wiltteri.txt/master/wiltteri.txt" }, "home.fredfiber.no/langsholt/adblock.txt": { "off": true, "title": "NOR: Norsk adblockliste", - "group": "regions" + "group": "regions", + "homeURL": "http://home.fredfiber.no/langsholt/adblock.txt" }, "www.fanboy.co.nz/fanboy-swedish.txt": { "off": true, "title": "SWE: Fanboy's Swedish", - "group": "regions" + "group": "regions", + "homeURL": "https://www.fanboy.co.nz/fanboy-swedish.txt" }, "adblock.gardar.net/is.abp.txt": { "off": true, "title": "ISL: Icelandic ABP List", - "group": "regions" + "group": "regions", + "homeURL": "http://adblock.gardar.net/is.abp.txt" }, "adblock.schack.dk/block.txt": { "off": true, "title": "DNK: Schacks Adblock Plus liste", - "group": "regions" + "group": "regions", + "homeURL": "http://adblock.schack.dk/block.txt" }, "www.void.gr/kargig/void-gr-filters.txt": { "off": true, "title": "GRC: Greek AdBlock Filter", - "group": "regions" + "group": "regions", + "homeURL": "https://www.void.gr/kargig/void-gr-filters.txt" }, "abp.mozilla-hispano.org/nauscopio/filtros.txt": { "off": true, "title": "ESP: Filtros Nauscopicos", - "group": "regions" + "group": "regions", + "homeURL": "http://abp.mozilla-hispano.org/nauscopio/filtros.txt" }, "www.hufilter.hu/hufilter.txt": { "off": true, "title": "HUN: hufilter (magyar)", - "group": "regions" + "group": "regions", + "homeURL": "http://www.hufilter.hu/hufilter.txt" }, "dl.dropboxusercontent.com/u/1289327/abpxfiles/filtri.txt": { "off": true, "title": "ITA: ABP X Files", - "group": "regions" + "group": "regions", + "homeURL": "https://dl.dropboxusercontent.com/u/1289327/abpxfiles/filtri.txt" }, "gitorious.org/adblock-latvian/adblock-latvian/raw/master_lists/latvian-list.txt": { "off": true, "title": "LVA: Latvian List", - "group": "regions" + "group": "regions", + "homeURL": "https://gitorious.org/adblock-latvian/adblock-latvian/raw/master%3Alists/latvian-list.txt" }, "www.fanboy.co.nz/fanboy-vietnam.txt": { "off": true, "title": "VIE: Fanboy's Vietnamese", - "group": "regions" + "group": "regions", + "homeURL": "https://www.fanboy.co.nz/fanboy-vietnam.txt" } } diff --git a/assets/update-3rdparties.sh b/assets/update-3rdparties.sh index eecfcd4d9..12aeae1dd 100755 --- a/assets/update-3rdparties.sh +++ b/assets/update-3rdparties.sh @@ -88,7 +88,7 @@ THIRDPARTY_LOCALURLS=( 'thirdparties/cjxlist1.googlecode.com/svn/cjxlist.txt' 'thirdparties/adblock-chinalist.googlecode.com/svn/trunk/adblock.txt' 'thirdparties/adblock-plus-japanese-filter.googlecode.com/hg/abp_jp.txt' - 'thirdparties/margevicius.lt/AdBlockPlusLithuania.txt' + 'thirdparties/margevicius.lt/easylistlithuania.txt' 'thirdparties/stanev.org/abp/adblock_bg.txt' 'thirdparties/indonesianadblockrules.googlecode.com/hg/subscriptions/abpindo.txt' 'thirdparties/liste-ar-adblock.googlecode.com/hg/Liste_AR.txt' diff --git a/js/assets.js b/js/assets.js index ad6876ac7..9e154adf7 100644 --- a/js/assets.js +++ b/js/assets.js @@ -254,51 +254,6 @@ var getRepoMetadata = function(callback) { lastRepoMetaTimestamp = Date.now(); - // https://github.com/gorhill/uBlock/issues/84 - // First try to load from the actual home server of a third-party. - var parseHomeURLs = function(text) { - var entries = repoMetadata.entries; - var urlPairs = text.split(/\n\n+/); - var i = urlPairs.length; - var pair, pos, k, v; - while ( i-- ) { - pair = urlPairs[i]; - pos = pair.indexOf('\n'); - if ( pos === -1 ) { - continue; - } - k = 'assets/thirdparties/' + pair.slice(0, pos).trim(); - v = pair.slice(pos).trim(); - if ( k === '' || v === '' ) { - continue; - } - if ( entries[k] === undefined ) { - entries[k] = new AssetEntry(); - } - entries[k].homeURL = v; - } - while ( callback = repoMetadata.waiting.pop() ) { - callback(repoMetadata); - } - }; - - var pathToHomeURLs = 'assets/ublock/thirdparty-lists.txt'; - - var onLocalHomeURLsLoaded = function(details) { - parseHomeURLs(details.content); - }; - - var onRepoHomeURLsLoaded = function(details) { - var entries = repoMetadata.entries; - var entry = entries[pathToHomeURLs]; - if ( YaMD5.hashStr(details.content) !== entry.repoChecksum ) { - entry.repoChecksum = entry.localChecksum; - readLocalFile(pathToHomeURLs, onLocalHomeURLsLoaded); - return; - } - cachedAssetsManager.save(pathToHomeURLs, details.content, onLocalHomeURLsLoaded); - }; - var localChecksums; var repoChecksums; @@ -330,11 +285,8 @@ var getRepoMetadata = function(callback) { updateLocalChecksums(); } // Fetch and store homeURL associations - entry = entries[pathToHomeURLs]; - if ( entry.localChecksum !== entry.repoChecksum ) { - readRepoFile(pathToHomeURLs, onRepoHomeURLsLoaded); - } else { - readLocalFile(pathToHomeURLs, onLocalHomeURLsLoaded); + while ( callback = repoMetadata.waiting.pop() ) { + callback(repoMetadata); } }; @@ -894,12 +846,6 @@ exports.put = function(path, content, callback) { /******************************************************************************/ -exports.purge = function(pattern, before) { - cachedAssetsManager.remove(pattern, before); -}; - -/******************************************************************************/ - exports.metadata = function(callback) { var out = {}; @@ -959,6 +905,22 @@ exports.metadata = function(callback) { /******************************************************************************/ +exports.setHomeURL = function(path, homeURL) { + var entry = repoMetadata[path]; + if ( entry === undefined ) { + entry = repoMetadata[path] = new AssetEntry(); + } + entry.homeURL = homeURL; +}; + +/******************************************************************************/ + +exports.purge = function(pattern, before) { + cachedAssetsManager.remove(pattern, before); +}; + +/******************************************************************************/ + exports.purgeAll = function(callback) { var onMetaDataReady = function(entries) { var out = {}; diff --git a/js/background.js b/js/background.js index 64b197542..ef52d70d9 100644 --- a/js/background.js +++ b/js/background.js @@ -44,10 +44,15 @@ return { logBlockedRequests: false, logAllowedRequests: false, parseAllABPHideFilters: true, - netExceptionList: {}, // TODO: remove once all users are up to date - netWhitelist: '', showIconBadge: true }, + + // https://github.com/gorhill/uBlock/issues/180 + // Whitelist directives need to be loaded once the PSL is available + netExceptionList: {}, // TODO: remove once all users are up to date + netWhitelist: {}, + netWhitelistModifyTime: 0, + localSettings: { blockedRequestCount: 0, allowedRequestCount: 0 @@ -81,8 +86,6 @@ return { remoteBlacklists: { }, - netWhitelist: {}, - netWhitelistModifyTime: 0, pageStores: {}, storageQuota: chrome.storage.local.QUOTA_BYTES, diff --git a/js/storage.js b/js/storage.js index 71004b912..be6bf56c6 100644 --- a/js/storage.js +++ b/js/storage.js @@ -72,6 +72,31 @@ µBlock.loadUserSettings = function(callback) { var settingsLoaded = function(store) { + µBlock.userSettings = store; + if ( typeof callback === 'function' ) { + callback(); + } + }; + + chrome.storage.local.get(this.userSettings, settingsLoaded); +}; + +/******************************************************************************/ + +µBlock.saveWhitelist = function() { + var bin = { + 'netWhitelist': this.stringFromWhitelist(this.netWhitelist) + }; + chrome.storage.local.set(bin, function() { + µBlock.getBytesInUse(); + }); + this.netWhitelistModifyTime = Date.now(); +}; + +/******************************************************************************/ + +µBlock.loadWhitelist = function(callback) { + var onWhitelistLoaded = function(store) { var µb = µBlock; // Backward compatibility after fix to #5 // TODO: remove once all users are up to date with latest version. @@ -82,28 +107,21 @@ chrome.storage.local.set({ 'netWhitelist': store.netWhitelist }); } } - delete store.netExceptionList; chrome.storage.local.remove('netExceptionList'); } - µb.userSettings = store; µb.netWhitelist = µb.whitelistFromString(store.netWhitelist); µb.netWhitelistModifyTime = Date.now(); - callback(); + if ( typeof callback === 'function' ) { + callback(); + } }; - chrome.storage.local.get(this.userSettings, settingsLoaded); -}; - -/******************************************************************************/ - -µBlock.saveWhitelist = function() { - this.userSettings.netWhitelist = this.stringFromWhitelist(this.netWhitelist); - var bin = { 'netWhitelist': this.userSettings.netWhitelist }; - chrome.storage.local.set(bin, function() { - µBlock.getBytesInUse(); - }); - this.netWhitelistModifyTime = Date.now(); + var bin = { + 'netWhitelist': '', + 'netExceptionList': '' + }; + chrome.storage.local.get(bin, onWhitelistLoaded); }; /******************************************************************************/ @@ -145,25 +163,32 @@ µBlock.getAvailableLists = function(callback) { var availableLists = {}; + var redirections = {}; // selected lists var onSelectedListsLoaded = function(store) { + var µb = µBlock; var lists = store.remoteBlacklists; var locations = Object.keys(lists); - var location; + var oldLocation, newLocation; + var availableEntry, storedEntry; - while ( location = locations.pop() ) { - if ( !availableLists[location] ) { + while ( oldLocation = locations.pop() ) { + newLocation = redirections[oldLocation] || oldLocation; + availableEntry = availableLists[newLocation]; + if ( availableEntry === undefined ) { continue; } - // https://github.com/gorhill/httpswitchboard/issues/218 - // Transfer potentially existing list title into restored list data. - if ( lists[location].title !== availableLists[location].title ) { - lists[location].title = availableLists[location].title; + storedEntry = lists[oldLocation]; + availableEntry.off = storedEntry.off || false; + µb.assets.setHomeURL(newLocation, availableEntry.homeURL); + if ( storedEntry.entryCount !== undefined ) { + availableEntry.entryCount = storedEntry.entryCount; + } + if ( storedEntry.entryUsedCount !== undefined ) { + availableEntry.entryUsedCount = storedEntry.entryUsedCount; } - availableLists[location] = lists[location]; } - callback(availableLists); }; @@ -175,11 +200,17 @@ } catch (e) { locations = {}; } + var entry; for ( location in locations ) { if ( locations.hasOwnProperty(location) === false ) { continue; } - availableLists['assets/thirdparties/' + location] = locations[location]; + entry = locations[location]; + availableLists['assets/thirdparties/' + location] = entry; + if ( entry.old !== undefined ) { + redirections[entry.old] = location; + delete entry.old; + } } // Now get user's selection of lists @@ -423,13 +454,16 @@ /******************************************************************************/ -µBlock.loadPublicSuffixList = function() { +µBlock.loadPublicSuffixList = function(callback) { var applyPublicSuffixList = function(details) { // TODO: Not getting proper suffix list is a bit serious, I think // the extension should be force-restarted if it occurs.. if ( !details.error ) { publicSuffixList.parse(details.content, punycode.toASCII); } + if ( typeof callback === 'function' ) { + callback(); + } }; this.assets.get( 'assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat', @@ -458,9 +492,23 @@ // Load all µBlock.load = function() { + var µb = this; + + // User whitelist directives and filters need the Public Suffix List to be + // available -- because the way they are stored internally. + var onPSLReady = function() { + µb.loadWhitelist(); + µb.loadUbiquitousBlacklists(); + }; + + // Public Suffix List loader needs the user settings need to be available + // because we need to know whether to auto-update the list or not. + var onUserSettingsReady = function() { + µb.assets.autoUpdate = µb.userSettings.autoUpdate || true; + µb.loadPublicSuffixList(onPSLReady); + }; + this.loadUserSettings(onUserSettingsReady); + this.loadLocalSettings(); - // User settings need to be available for this because we need - // µBlock.userSettings.externalLists - this.loadUserSettings(this.loadUpdatableAssets.bind(this)); this.getBytesInUse(); }; diff --git a/js/ublock.js b/js/ublock.js index cce9aa51a..fe158ba62 100644 --- a/js/ublock.js +++ b/js/ublock.js @@ -34,7 +34,7 @@ domain = this.URI.domainFromHostname(keyHostname); } if ( !domain ) { - return false; + return true; } var exceptions = this.netWhitelist[domain]; diff --git a/manifest.json b/manifest.json index 7df3b1222..d8623f9f3 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_extName__", "short_name": "µBlock", - "version": "0.5.0.1", + "version": "0.5.1.0", "description": "__MSG_extShortDesc__", "icons": { "16": "img/icon_16.png",