1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-20 01:12:38 +01:00

Assets management refactored (#2314)

* refactoring assets management code

* finalizing refactoring of assets management

* various code review of new assets management code

* fix #2281

* fix #1961

* fix #1293

* fix #1275

* fix update scheduler timing logic

* forward compatibility (to be removed once 1.11+ is widespread)

* more codereview; give admins ability to specify own assets.json

* "assetKey" is more accurate than "path"

* fix group count update when building dom incrementally

* reorganize content (order, added URLs, etc.)

* ability to customize updater through advanced settings

* better spinner icon
This commit is contained in:
Raymond Hill 2017-01-18 13:17:47 -05:00 committed by GitHub
parent 69fc59305e
commit 3b9fd49c50
20 changed files with 2171 additions and 2525 deletions

585
assets/assets.json Normal file
View File

@ -0,0 +1,585 @@
{
"assets.json": {
"content": "internal",
"updateAfter": 13,
"contentURL": [
"https://raw.githubusercontent.com/gorhill/uBlock/master/assets/assets.json",
"assets/assets.json"
]
},
"public_suffix_list.dat": {
"content": "internal",
"updateAfter": 19,
"contentURL": [
"https://publicsuffix.org/list/public_suffix_list.dat",
"assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat"
]
},
"ublock-resources": {
"content": "internal",
"updateAfter": 7,
"contentURL": [
"https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/resources.txt",
"assets/ublock/resources.txt"
]
},
"ublock-filters": {
"content": "filters",
"group": "default",
"title": "uBlock filters",
"contentURL": [
"https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt",
"assets/ublock/filters.txt"
]
},
"ublock-badware": {
"content": "filters",
"group": "default",
"title": "uBlock filters Badware risks",
"contentURL": [
"https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/badware.txt",
"assets/ublock/badware.txt"
],
"supportURL": "https://github.com/gorhill/uBlock/wiki/Badware-risks",
"instructionURL": "https://github.com/gorhill/uBlock/wiki/Badware-risks"
},
"ublock-experimental": {
"content": "filters",
"group": "default",
"title": "uBlock filters Experimental",
"off": true,
"contentURL": [
"https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/experimental.txt",
"assets/ublock/experimental.txt"
],
"supportURL": "https://github.com/gorhill/uBlock/wiki/Experimental-filters",
"instructionURL": "https://github.com/gorhill/uBlock/wiki/Experimental-filters"
},
"ublock-privacy": {
"content": "filters",
"group": "default",
"title": "uBlock filters Privacy",
"contentURL": [
"https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/privacy.txt",
"assets/ublock/privacy.txt"
]
},
"ublock-unbreak": {
"content": "filters",
"group": "default",
"title": "uBlock filters Unbreak",
"contentURL": [
"https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/unbreak.txt",
"assets/ublock/unbreak.txt"
]
},
"awrl-0": {
"content": "filters",
"group": "ads",
"off": true,
"title": "Adblock Warning Removal List",
"contentURL": "https://easylist-downloads.adblockplus.org/antiadblockfilters.txt",
"supportURL": "https://forums.lanik.us/"
},
"reek-0": {
"content": "filters",
"group": "ads",
"off": true,
"title": "Anti-Adblock Killer | Reek",
"contentURL": "https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt",
"supportURL": "https://github.com/reek/anti-adblock-killer",
"instructionURL": "https://github.com/reek/anti-adblock-killer#instruction"
},
"easylist": {
"content": "filters",
"group": "ads",
"title": "EasyList",
"contentURL": [
"https://easylist.to/easylist/easylist.txt",
"https://easylist-downloads.adblockplus.org/easylist.txt",
"https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/thirdparties/easylist-downloads.adblockplus.org/easylist.txt",
"assets/thirdparties/easylist-downloads.adblockplus.org/easylist.txt"
],
"supportURL": "https://forums.lanik.us/"
},
"easylist-nocosmetic": {
"content": "filters",
"group": "ads",
"off": true,
"title": "EasyList without element hiding rules",
"contentURL": "https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt",
"supportURL": "https://forums.lanik.us/"
},
"disconnect-tracking": {
"content": "filters",
"group": "privacy",
"off": true,
"title": "Basic tracking list by Disconnect",
"contentURL": "https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt"
},
"easyprivacy": {
"content": "filters",
"group": "privacy",
"title": "EasyPrivacy",
"contentURL": [
"https://easylist.to/easylist/easyprivacy.txt",
"https://easylist-downloads.adblockplus.org/easyprivacy.txt",
"https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/thirdparties/easylist-downloads.adblockplus.org/easyprivacy.txt",
"assets/thirdparties/easylist-downloads.adblockplus.org/easyprivacy.txt"
],
"supportURL": "https://forums.lanik.us/"
},
"fanboy-enhanced": {
"content": "filters",
"group": "privacy",
"off": true,
"title": "Fanboys Enhanced Tracking List",
"contentURL": "https://www.fanboy.co.nz/enhancedstats.txt",
"supportURL": "https://forums.lanik.us/"
},
"disconnect-malvertising": {
"content": "filters",
"group": "malware",
"off": true,
"title": "Malvertising filter list by Disconnect",
"contentURL": "https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt"
},
"malware-0": {
"content": "filters",
"group": "malware",
"title": "Malware Domain List",
"contentURL": [
"https://www.malwaredomainlist.com/hostslist/hosts.txt",
"assets/thirdparties/www.malwaredomainlist.com/hostslist/hosts.txt"
]
},
"malware-1": {
"content": "filters",
"group": "malware",
"title": "Malware domains",
"contentURL": [
"https://mirror.cedia.org.ec/malwaredomains/justdomains",
"https://mirror1.malwaredomains.com/files/justdomains",
"assets/thirdparties/mirror1.malwaredomains.com/files/justdomains",
"assets/thirdparties/mirror1.malwaredomains.com/files/justdomains.txt"
],
"supportURL": "http://www.malwaredomains.com/"
},
"malware-2": {
"content": "filters",
"group": "malware",
"off": true,
"title": "Malware domains (long-lived)",
"contentURL": [
"https://mirror1.malwaredomains.com/files/immortal_domains.txt",
"https://mirror.cedia.org.ec/malwaredomains/immortal_domains.txt"
],
"supportURL": "http://www.malwaredomains.com/"
},
"disconnect-malware": {
"content": "filters",
"group": "malware",
"off": true,
"title": "Malware filter list by Disconnect",
"contentURL": "https://s3.amazonaws.com/lists.disconnect.me/simple_malware.txt"
},
"spam404-0": {
"content": "filters",
"group": "malware",
"off": true,
"title": "Spam404",
"contentURL": "https://raw.githubusercontent.com/Dawsey21/Lists/master/adblock-list.txt",
"supportURL": "http://www.spam404.com/"
},
"fanboy-thirdparty_social": {
"content": "filters",
"group": "social",
"off": true,
"title": "Anti-ThirdpartySocial (see warning inside list)",
"contentURL": "https://www.fanboy.co.nz/fanboy-antifacebook.txt",
"supportURL": "https://forums.lanik.us/"
},
"fanboy-annoyance": {
"content": "filters",
"group": "social",
"off": true,
"title": "Fanboys Annoyance List",
"contentURL": [
"https://easylist.to/easylist/fanboy-annoyance.txt",
"https://easylist-downloads.adblockplus.org/fanboy-annoyance.txt"
],
"supportURL": "https://forums.lanik.us/"
},
"fanboy-social": {
"content": "filters",
"group": "social",
"off": true,
"title": "Fanboys Social Blocking List",
"contentURL": [
"https://easylist.to/easylist/fanboy-social.txt",
"https://easylist-downloads.adblockplus.org/fanboy-social.txt"
],
"supportURL": "https://forums.lanik.us/"
},
"dpollock-0": {
"content": "filters",
"group": "multipurpose",
"updateAfter": 11,
"off": true,
"title": "Dan Pollocks hosts file",
"contentURL": "http://someonewhocares.org/hosts/hosts",
"supportURL": "http://someonewhocares.org/hosts/"
},
"fanboy-ultimate": {
"content": "filters",
"group": "multipurpose",
"off": true,
"title": "Fanboy+Easylist-Merged Ultimate List",
"contentURL": "https://www.fanboy.co.nz/r/fanboy-ultimate.txt",
"supportURL": "https://forums.lanik.us/"
},
"hphosts": {
"content": "filters",
"group": "multipurpose",
"updateAfter": 11,
"off": true,
"title": "hpHosts Ad and tracking servers",
"contentURL": "https://hosts-file.net/.%5Cad_servers.txt",
"supportURL": "https://hosts-file.net/"
},
"mvps-0": {
"content": "filters",
"group": "multipurpose",
"updateAfter": 11,
"off": true,
"title": "MVPS HOSTS",
"contentURL": "http://winhelp2002.mvps.org/hosts.txt",
"supportURL": "http://winhelp2002.mvps.org/"
},
"plowe-0": {
"content": "filters",
"group": "multipurpose",
"updateAfter": 13,
"title": "Peter Lowes Ad and tracking server list",
"contentURL": [
"https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext",
"assets/thirdparties/pgl.yoyo.org/as/serverlist",
"assets/thirdparties/pgl.yoyo.org/as/serverlist.txt"
],
"supportURL": "https://pgl.yoyo.org/adservers/"
},
"ara-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "ara: Liste AR",
"lang": "ar",
"contentURL": "https://easylist-downloads.adblockplus.org/Liste_AR.txt",
"supportURL": "https://forums.lanik.us/viewforum.php?f=98"
},
"BGR-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "BGR: Bulgarian Adblock list",
"lang": "bg",
"contentURL": "https://stanev.org/abp/adblock_bg.txt",
"supportURL": "https://stanev.org/abp/"
},
"CHN-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "CHN: EasyList China (中文)",
"lang": "zh",
"contentURL": "https://easylist-downloads.adblockplus.org/easylistchina.txt",
"supportURL": "http://abpchina.org/forum/forum.php"
},
"CHN-1": {
"content": "filters",
"group": "regions",
"off": true,
"title": "CHN: CJX's EasyList Lite (main focus on Chinese sites)",
"contentURL": "https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjxlist.txt",
"supportURL": "https://github.com/cjx82630/cjxlist"
},
"CHN-2": {
"content": "filters",
"group": "regions",
"off": true,
"title": "CHN: CJX's Annoyance List",
"contentURL": "https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjx-annoyance.txt",
"supportURL": "https://github.com/cjx82630/cjxlist"
},
"CZE-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "CZE, SVK: EasyList Czech and Slovak",
"lang": "cs",
"contentURL": "https://raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt",
"supportURL": "https://github.com/tomasko126/easylistczechandslovak"
},
"DEU-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "DEU: EasyList Germany",
"lang": "de",
"contentURL": [
"https://easylist.to/easylistgermany/easylistgermany.txt",
"https://easylist-downloads.adblockplus.org/easylistgermany.txt"
],
"supportURL": "https://forums.lanik.us/viewforum.php?f=90"
},
"DNK-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "DNK: Schacks Adblock Plus liste",
"lang": "da",
"contentURL": "https://adblock.dk/block.csv",
"supportURL": "https://henrik.schack.dk/adblock/"
},
"EST-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "EST: Eesti saitidele kohandatud filter",
"lang": "et",
"contentURL": "http://adblock.ee/list.php",
"supportURL": "http://adblock.ee/"
},
"EU-prebake": {
"content": "filters",
"group": "regions",
"off": true,
"title": "EU: Prebake - Filter Obtrusive Cookie Notices",
"contentURL": "https://raw.githubusercontent.com/liamja/Prebake/master/obtrusive.txt",
"supportURL": "https://github.com/liamja/Prebake"
},
"FIN-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "FIN: Finnish Addition to Easylist",
"lang": "fi",
"contentURL": "http://adb.juvander.net/Finland_adb.txt",
"supportURL": "http://www.juvander.fi/AdblockFinland"
},
"FRA-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "FRA: EasyList Liste FR",
"lang": "fr",
"contentURL": "https://easylist-downloads.adblockplus.org/liste_fr.txt",
"supportURL": "https://forums.lanik.us/viewforum.php?f=91"
},
"GRC-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "GRC: Greek AdBlock Filter",
"lang": "el",
"contentURL": "https://www.void.gr/kargig/void-gr-filters.txt",
"supportURL": "https://github.com/kargig/greek-adblockplus-filter"
},
"HUN-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "HUN: hufilter",
"lang": "hu",
"contentURL": "https://raw.githubusercontent.com/szpeter80/hufilter/master/hufilter.txt",
"supportURL": "https://github.com/szpeter80/hufilter"
},
"IDN-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "IDN: ABPindo",
"lang": "id",
"contentURL": [
"https://raw.githubusercontent.com/ABPindo/indonesianadblockrules/master/subscriptions/abpindo.txt",
"https://raw.githubusercontent.com/heradhis/indonesianadblockrules/master/subscriptions/abpindo.txt"
],
"supportURL": "https://github.com/ABPindo/indonesianadblockrules"
},
"ISL-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "ISL: Icelandic ABP List",
"lang": "is",
"contentURL": "http://adblock.gardar.net/is.abp.txt",
"supportURL": "http://adblock.gardar.net/"
},
"ISR-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "ISR: EasyList Hebrew",
"lang": "he",
"contentURL": "https://raw.githubusercontent.com/easylist/EasyListHebrew/master/EasyListHebrew.txt",
"supportURL": "https://github.com/easylist/EasyListHebrew"
},
"ITA-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "ITA: EasyList Italy",
"lang": "it",
"contentURL": "https://easylist-downloads.adblockplus.org/easylistitaly.txt",
"supportURL": "https://forums.lanik.us/viewforum.php?f=96"
},
"ITA-1": {
"content": "filters",
"group": "regions",
"off": true,
"title": "ITA: ABP X Files",
"contentURL": "https://raw.githubusercontent.com/gioxx/xfiles/master/filtri.txt",
"supportURL": "http://noads.it/"
},
"JPN-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "JPN: ABP Japanese filters (日本用フィルタ)",
"lang": "ja",
"contentURL": "https://raw.githubusercontent.com/k2jp/abp-japanese-filters/master/abpjf.txt",
"supportURL": "https://github.com/k2jp/abp-japanese-filters/wiki/Support_Policy"
},
"KOR-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "KOR: Korean Adblock List",
"lang": "ko",
"contentURL": "https://raw.githubusercontent.com/gfmaster/adblock-korea-contrib/master/filter.txt",
"supportURL": "https://github.com/gfmaster/adblock-korea-contrib"
},
"KOR-1": {
"content": "filters",
"group": "regions",
"off": true,
"title": "KOR: YousList",
"lang": "ko",
"contentURL": "https://raw.githubusercontent.com/yous/YousList/master/youslist.txt",
"supportURL": "https://github.com/yous/YousList"
},
"KOR-2": {
"content": "filters",
"group": "regions",
"off": true,
"title": "KOR: Fanboy's Korean",
"contentURL": "https://www.fanboy.co.nz/fanboy-korean.txt",
"supportURL": "https://forums.lanik.us/"
},
"LTU-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "LTU: Adblock Plus Lithuania",
"lang": "lt",
"contentURL": "http://margevicius.lt/easylistlithuania.txt",
"supportURL": "http://margevicius.lt/easylist_lithuania/"
},
"LVA-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "LVA: Latvian List",
"lang": "lv",
"contentURL": "https://notabug.org/latvian-list/adblock-latvian/raw/master/lists/latvian-list.txt",
"supportURL": "https://notabug.org/latvian-list/adblock-latvian"
},
"NLD-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "NLD: EasyList Dutch",
"lang": "nl",
"contentURL": "https://easylist-downloads.adblockplus.org/easylistdutch.txt",
"supportURL": "https://forums.lanik.us/viewforum.php?f=100"
},
"POL-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "POL: polskie filtry do Adblocka i uBlocka",
"lang": "pl",
"contentURL": "https://raw.githubusercontent.com/MajkiIT/polish-ads-filter/master/polish-adblock-filters/adblock.txt",
"supportURL": "https://www.certyficate.it/adblock-ublock-polish-filters/"
},
"RUS-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "RUS: RU AdList (Дополнительная региональная подписка)",
"lang": "ru",
"contentURL": "https://easylist-downloads.adblockplus.org/advblock.txt",
"supportURL": "https://forums.lanik.us/viewforum.php?f=102"
},
"RUS-1": {
"content": "filters",
"group": "regions",
"off": true,
"title": "RUS: BitBlock List (Дополнительная подписка фильтров)",
"contentURL": "https://easylist-downloads.adblockplus.org/bitblock.txt",
"supportURL": "https://forums.lanik.us/viewforum.php?f=102"
},
"RUS-2": {
"content": "filters",
"group": "regions",
"off": true,
"title": "RUS: Adguard Russian Filter",
"contentURL": "https://filters.adtidy.org/extension/chromium/filters/1.txt",
"supportURL": "https://forum.adguard.com/forumdisplay.php?69-%D0%A4%D0%B8%D0%BB%D1%8C%D1%82%D1%80%D1%8B-Adguard"
},
"spa-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "spa: EasyList Spanish",
"lang": "es",
"contentURL": "https://easylist-downloads.adblockplus.org/easylistspanish.txt",
"supportURL": "https://forums.lanik.us/viewforum.php?f=103"
},
"SVN-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "SVN: Slovenian List",
"lang": "sl",
"contentURL": "https://raw.githubusercontent.com/betterwebleon/slovenian-list/master/filters.txt",
"supportURL": "https://github.com/betterwebleon/slovenian-list"
},
"SWE-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "SWE: Fanboy's Swedish",
"lang": "sv",
"contentURL": "https://www.fanboy.co.nz/fanboy-swedish.txt",
"supportURL": "https://forums.lanik.us/"
},
"TUR-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "TUR: Adguard Turkish Filter",
"lang": "tr",
"contentURL": "https://filters.adtidy.org/extension/chromium/filters/13.txt",
"supportURL": "https://forum.adguard.com/forumdisplay.php?51-Filter-Rules"
},
"VIE-0": {
"content": "filters",
"group": "regions",
"off": true,
"title": "VIE: Fanboy's Vietnamese",
"lang": "vi",
"contentURL": "https://www.fanboy.co.nz/fanboy-vietnam.txt",
"supportURL": "https://forums.lanik.us/"
}
}

View File

@ -40,16 +40,10 @@
<button id="externalListsApply" class="custom important" disabled="true" data-i18n="3pExternalListsApply"></button></p> <button id="externalListsApply" class="custom important" disabled="true" data-i18n="3pExternalListsApply"></button></p>
</div> </div>
<div id="busyOverlay">
<div></div>
<!-- progress bar widget -->
<div><div></div><div></div></div>
</div>
<div id="templates" style="display: none;"> <div id="templates" style="display: none;">
<ul> <ul>
<li class="groupEntry"><span class="geName"></span> <span class="geCount dim"></span> <li class="groupEntry"><span class="geName"></span> <span class="geCount dim"></span>
<ul></ul> <ul class="listEntries"></ul>
</li> </li>
<li class="listEntry"> <li class="listEntry">
<input type="checkbox"> <input type="checkbox">
@ -57,10 +51,10 @@
<a class="fa" style="display: none;" target="_blank">&#xf05a;</a> <a class="fa" style="display: none;" target="_blank">&#xf05a;</a>
<a href="" style="display: none;" target="_blank"></a>: <!-- <a href="" style="display: none;" target="_blank"></a>: <!--
--><span class="counts dim"></span><!-- --><span class="counts dim"></span><!--
--><span class="status unsecure" style="display: none;">http</span><!-- --><span class="status unsecure">http</span><!--
--><span class="status new" style="display: none;" data-i18n="3pExternalListNew"></span><!-- --><span class="status obsolete" data-i18n="3pExternalListObsolete"></span><!--
--><span class="status obsolete" style="display: none;" data-i18n="3pExternalListObsolete"></span><!-- --><span class="status purge" data-i18n="3pExternalListPurge"></span><!--
--><span class="status purge" style="display: none;" data-i18n="3pExternalListPurge"></span> --><span class="fa status updating">&#xf110;</span>
</li> </li>
</ul> </ul>
</div> </div>

View File

@ -580,8 +580,8 @@
"description": "Message asking user to confirm reset" "description": "Message asking user to confirm reset"
}, },
"errorCantConnectTo":{ "errorCantConnectTo":{
"message":"Unable to connect to {{url}}", "message":"Network error: {{msg}}",
"description":"English: Network error: unable to connect to {{url}}" "description":"English: Network error: {{msg}}"
}, },
"subscriberConfirm":{ "subscriberConfirm":{
"message":"uBlock₀: Add the following URL to your custom filter lists?\n\nTitle: \"{{title}}\"\nURL: {{url}}", "message":"uBlock₀: Add the following URL to your custom filter lists?\n\nTitle: \"{{title}}\"\nURL: {{url}}",

View File

@ -8,7 +8,6 @@
<script src="js/polyfill.js"></script> <script src="js/polyfill.js"></script>
<script src="lib/punycode.js"></script> <script src="lib/punycode.js"></script>
<script src="lib/publicsuffixlist.js"></script> <script src="lib/publicsuffixlist.js"></script>
<script src="lib/yamd5.js"></script>
<script src="js/vapi-common.js"></script> <script src="js/vapi-common.js"></script>
<script src="js/vapi-background.js"></script> <script src="js/vapi-background.js"></script>
<script src="js/background.js"></script> <script src="js/background.js"></script>

View File

@ -1,3 +1,7 @@
@keyframes spin {
100% { transform: rotate(360deg); -webkit-transform: rotate(360deg); }
}
ul { ul {
padding: 0; padding: 0;
list-style-type: none; list-style-type: none;
@ -88,7 +92,7 @@ body[dir=rtl] #buttonApply {
span.status { span.status {
border: 1px solid transparent; border: 1px solid transparent;
color: #444; color: #444;
display: inline-block; display: none;
font-size: smaller; font-size: smaller;
line-height: 1; line-height: 1;
margin: 0 0 0 0.5em; margin: 0 0 0 0.5em;
@ -99,6 +103,16 @@ span.unsecure {
background-color: hsl(0, 100%, 88%); background-color: hsl(0, 100%, 88%);
border-color: hsl(0, 100%, 83%); border-color: hsl(0, 100%, 83%);
} }
li.listEntry.unsecure span.unsecure {
display: inline;
}
span.obsolete {
background-color: hsl(36, 100%, 80%);
border-color: hsl(36, 100%, 75%);
}
li.listEntry.obsolete > input[type="checkbox"]:checked ~ span.obsolete {
display: inline;
}
span.purge { span.purge {
border-color: #ddd; border-color: #ddd;
background-color: #eee; background-color: #eee;
@ -107,10 +121,16 @@ span.purge {
span.purge:hover { span.purge:hover {
opacity: 1; opacity: 1;
} }
span.obsolete, li.listEntry.cached span.purge {
span.new { display: inline;
background-color: hsl(36, 100%, 80%); }
border-color: hsl(36, 100%, 75%); span.updating {
border: none;
padding: 0;
}
li.listEntry.updating span.updating {
animation: spin 2s linear infinite;
display: inline-block;
} }
#externalListsDiv { #externalListsDiv {
margin: 2em auto 0 2em; margin: 2em auto 0 2em;
@ -125,64 +145,3 @@ body[dir=rtl] #externalListsDiv {
width: 100%; width: 100%;
word-wrap: normal; word-wrap: normal;
} }
body #busyOverlay {
background-color: transparent;
bottom: 0;
cursor: wait;
display: none;
left: 0;
position: fixed;
right: 0;
top: 0;
z-index: 1000;
}
body.busy #busyOverlay {
display: block;
}
#busyOverlay > div:nth-of-type(1) {
background-color: white;
bottom: 0;
left: 0;
opacity: 0.75;
position: absolute;
right: 0;
top: 0;
}
#busyOverlay > div:nth-of-type(2) {
background-color: #eee;
border: 1px solid transparent;
border-color: #80b3ff #80b3ff hsl(216, 100%, 75%);
border-radius: 3px;
box-sizing: border-box;
height: 3em;
left: 10%;
position: absolute;
bottom: 75%;
width: 80%;
}
#busyOverlay > div:nth-of-type(2) > div:nth-of-type(1) {
background-color: hsl(216, 100%, 75%);
background-image: linear-gradient(#a8cbff, #80b3ff);
background-repeat: repeat-x;
border: 0;
box-sizing: border-box;
color: #222;
height: 100%;
left: 0;
padding: 0;
position: absolute;
width: 25%;
}
#busyOverlay > div:nth-of-type(2) > div:nth-of-type(2) {
background-color: transparent;
border: 0;
box-sizing: border-box;
height: 100%;
left: 0;
line-height: 3em;
overflow: hidden;
position: absolute;
text-align: center;
top: 0;
width: 100%;
}

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
uBlock Origin - a browser extension to block requests. uBlock Origin - a browser extension to block requests.
Copyright (C) 2014-2016 Raymond Hill Copyright (C) 2014-2017 Raymond Hill
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -21,38 +21,30 @@
/* global uDom */ /* global uDom */
/******************************************************************************/
(function() {
'use strict'; 'use strict';
/******************************************************************************/ /******************************************************************************/
var userListName = vAPI.i18n('1pPageName'); (function() {
/******************************************************************************/
var listDetails = {}; var listDetails = {};
var parseCosmeticFilters = true; var parseCosmeticFilters = true;
var ignoreGenericCosmeticFilters = false; var ignoreGenericCosmeticFilters = false;
var selectedListsHashBefore = '';
var externalLists = ''; var externalLists = '';
var cacheWasPurged = false;
var needUpdate = false;
var hasCachedContent = false;
/******************************************************************************/ /******************************************************************************/
var onMessage = function(msg) { var onMessage = function(msg) {
switch ( msg.what ) { switch ( msg.what ) {
case 'assetUpdated':
updateAssetStatus(msg);
break;
case 'staticFilteringDataChanged': case 'staticFilteringDataChanged':
renderFilterLists(); renderFilterLists();
break; break;
case 'forceUpdateAssetsProgress':
renderBusyOverlay(true, msg.progress);
if ( msg.done ) {
messaging.send('dashboard', { what: 'reloadAllFilters' });
}
break;
default: default:
break; break;
} }
@ -69,20 +61,15 @@ var renderNumber = function(value) {
/******************************************************************************/ /******************************************************************************/
// TODO: get rid of background page dependencies
var renderFilterLists = function() { var renderFilterLists = function() {
var listGroupTemplate = uDom('#templates .groupEntry'); var listGroupTemplate = uDom('#templates .groupEntry'),
var listEntryTemplate = uDom('#templates .listEntry'); listEntryTemplate = uDom('#templates .listEntry'),
var listStatsTemplate = vAPI.i18n('3pListsOfBlockedHostsPerListStats'); listStatsTemplate = vAPI.i18n('3pListsOfBlockedHostsPerListStats'),
var renderElapsedTimeToString = vAPI.i18n.renderElapsedTimeToString; renderElapsedTimeToString = vAPI.i18n.renderElapsedTimeToString,
var lastUpdateString = vAPI.i18n('3pLastUpdate'); lastUpdateString = vAPI.i18n('3pLastUpdate');
// Assemble a pretty blacklist name if possible // Assemble a pretty list name if possible
var listNameFromListKey = function(listKey) { var listNameFromListKey = function(listKey) {
if ( listKey === listDetails.userFiltersPath ) {
return userListName;
}
var list = listDetails.current[listKey] || listDetails.available[listKey]; var list = listDetails.current[listKey] || listDetails.available[listKey];
var listTitle = list ? list.title : ''; var listTitle = list ? list.title : '';
if ( listTitle === '' ) { if ( listTitle === '' ) {
@ -91,73 +78,68 @@ var renderFilterLists = function() {
return listTitle; return listTitle;
}; };
var liFromListEntry = function(listKey) { var liFromListEntry = function(listKey, li) {
var entry = listDetails.available[listKey]; var entry = listDetails.available[listKey];
var li = listEntryTemplate.clone(); li = li ? li : listEntryTemplate.clone().nodeAt(0);
li.setAttribute('data-listkey', listKey);
var elem = li.querySelector('input[type="checkbox"]');
if ( entry.off !== true ) { if ( entry.off !== true ) {
li.descendants('input').attr('checked', ''); elem.setAttribute('checked', '');
} else {
elem.removeAttribute('checked');
} }
elem = li.querySelector('a:nth-of-type(1)');
var elem = li.descendants('a:nth-of-type(1)'); elem.setAttribute('href', 'asset-viewer.html?url=' + encodeURI(listKey));
elem.attr('href', 'asset-viewer.html?url=' + encodeURI(listKey)); elem.setAttribute('type', 'text/html');
elem.attr('type', 'text/html'); elem.textContent = listNameFromListKey(listKey) + '\u200E';
elem.attr('data-listkey', listKey); elem = li.querySelector('a:nth-of-type(2)');
elem.text(listNameFromListKey(listKey) + '\u200E');
if ( entry.instructionURL ) { if ( entry.instructionURL ) {
elem = li.descendants('a:nth-of-type(2)'); elem.setAttribute('href', entry.instructionURL);
elem.attr('href', entry.instructionURL); elem.style.setProperty('display', '');
elem.css('display', ''); } else {
elem.style.setProperty('display', 'none');
} }
elem = li.querySelector('a:nth-of-type(3)');
if ( entry.supportName ) { if ( entry.supportName ) {
elem = li.descendants('a:nth-of-type(3)'); elem.setAttribute('href', entry.supportURL);
elem.attr('href', entry.supportURL); elem.textContent = '(' + entry.supportName + ')';
elem.text('(' + entry.supportName + ')'); elem.style.setProperty('display', '');
elem.css('display', ''); } else {
elem.style.setProperty('display', 'none');
} }
elem = li.querySelector('span.counts');
elem = li.descendants('span.counts');
var text = listStatsTemplate var text = listStatsTemplate
.replace('{{used}}', renderNumber(!entry.off && !isNaN(+entry.entryUsedCount) ? entry.entryUsedCount : 0)) .replace('{{used}}', renderNumber(!entry.off && !isNaN(+entry.entryUsedCount) ? entry.entryUsedCount : 0))
.replace('{{total}}', !isNaN(+entry.entryCount) ? renderNumber(entry.entryCount) : '?'); .replace('{{total}}', !isNaN(+entry.entryCount) ? renderNumber(entry.entryCount) : '?');
elem.text(text); elem.textContent = text;
// https://github.com/gorhill/uBlock/issues/78
// Badge for non-secure connection
var remoteURL = listKey;
if ( remoteURL.lastIndexOf('http:', 0) !== 0 ) {
remoteURL = entry.homeURL || '';
}
if ( remoteURL.lastIndexOf('http:', 0) === 0 ) {
li.descendants('span.status.unsecure').css('display', '');
}
// https://github.com/chrisaljoudi/uBlock/issues/104 // https://github.com/chrisaljoudi/uBlock/issues/104
var asset = listDetails.cache[listKey] || {}; var asset = listDetails.cache[listKey] || {};
// https://github.com/gorhill/uBlock/issues/78
// Badge for non-secure connection
var remoteURL = asset.remoteURL;
li.classList.toggle(
'unsecure',
typeof remoteURL === 'string' && remoteURL.lastIndexOf('http:', 0) === 0
);
// Badge for update status // Badge for update status
if ( entry.off !== true ) { li.classList.toggle(
if ( asset.repoObsolete ) { 'obsolete',
li.descendants('span.status.new').css('display', ''); entry.off !== true && asset.obsolete === true
needUpdate = true; );
} else if ( asset.cacheObsolete ) { // Badge for cache status
li.descendants('span.status.obsolete').css('display', ''); li.classList.toggle(
needUpdate = true; 'cached',
} else if ( entry.external && !asset.cached ) { asset.cached === true && asset.writeTime > 0
li.descendants('span.status.obsolete').css('display', ''); );
needUpdate = true;
}
}
// In cache
if ( asset.cached ) { if ( asset.cached ) {
elem = li.descendants('span.status.purge'); li.querySelector('.status.purge').setAttribute(
elem.css('display', ''); 'title',
elem.attr('title', lastUpdateString.replace('{{ago}}', renderElapsedTimeToString(asset.lastModified))); lastUpdateString.replace('{{ago}}', renderElapsedTimeToString(asset.writeTime))
hasCachedContent = true; );
} }
li.classList.remove('discard');
return li; return li;
}; };
@ -176,27 +158,31 @@ var renderFilterLists = function() {
}; };
var liFromListGroup = function(groupKey, listKeys) { var liFromListGroup = function(groupKey, listKeys) {
var liGroup = listGroupTemplate.clone(); var liGroup = document.querySelector('#lists > .groupEntry[data-groupkey="' + groupKey + '"]');
var groupName = vAPI.i18n('3pGroup' + groupKey.charAt(0).toUpperCase() + groupKey.slice(1)); if ( liGroup === null ) {
if ( groupName !== '' ) { liGroup = listGroupTemplate.clone().nodeAt(0);
liGroup.descendants('span.geName').text(groupName); var groupName = vAPI.i18n('3pGroup' + groupKey.charAt(0).toUpperCase() + groupKey.slice(1));
liGroup.descendants('span.geCount').text(listEntryCountFromGroup(listKeys)); if ( groupName !== '' ) {
liGroup.querySelector('.geName').textContent = groupName;
}
} }
var ulGroup = liGroup.descendants('ul'); if ( liGroup.querySelector('.geName:empty') === null ) {
if ( !listKeys ) { liGroup.querySelector('.geCount').textContent = listEntryCountFromGroup(listKeys);
return liGroup;
} }
var ulGroup = liGroup.querySelector('.listEntries');
if ( !listKeys ) { return liGroup; }
listKeys.sort(function(a, b) { listKeys.sort(function(a, b) {
return (listDetails.available[a].title || '').localeCompare(listDetails.available[b].title || ''); return (listDetails.available[a].title || '').localeCompare(listDetails.available[b].title || '');
}); });
for ( var i = 0; i < listKeys.length; i++ ) { for ( var i = 0; i < listKeys.length; i++ ) {
ulGroup.append(liFromListEntry(listKeys[i])); var liEntry = liFromListEntry(listKeys[i], ulGroup.children[i]);
if ( liEntry.parentElement === null ) {
ulGroup.appendChild(liEntry);
}
} }
return liGroup; return liGroup;
}; };
// https://www.youtube.com/watch?v=unCVi4hYRlY#t=30m18s
var groupsFromLists = function(lists) { var groupsFromLists = function(lists) {
var groups = {}; var groups = {};
var listKeys = Object.keys(lists); var listKeys = Object.keys(lists);
@ -219,14 +205,16 @@ var renderFilterLists = function() {
listDetails = details; listDetails = details;
parseCosmeticFilters = details.parseCosmeticFilters; parseCosmeticFilters = details.parseCosmeticFilters;
ignoreGenericCosmeticFilters = details.ignoreGenericCosmeticFilters; ignoreGenericCosmeticFilters = details.ignoreGenericCosmeticFilters;
needUpdate = false;
hasCachedContent = false; // Incremental rendering: this will allow us to easily discard unused
// DOM list entries.
uDom('#lists .listEntries .listEntry').addClass('discard');
// Visually split the filter lists in purpose-based groups // Visually split the filter lists in purpose-based groups
var ulLists = uDom('#lists').empty(), liGroup; var ulLists = document.querySelector('#lists'),
var groups = groupsFromLists(details.available); groups = groupsFromLists(details.available),
var groupKey, i; liGroup, i, groupKey,
var groupKeys = [ groupKeys = [
'default', 'default',
'ads', 'ads',
'privacy', 'privacy',
@ -239,31 +227,44 @@ var renderFilterLists = function() {
for ( i = 0; i < groupKeys.length; i++ ) { for ( i = 0; i < groupKeys.length; i++ ) {
groupKey = groupKeys[i]; groupKey = groupKeys[i];
liGroup = liFromListGroup(groupKey, groups[groupKey]); liGroup = liFromListGroup(groupKey, groups[groupKey]);
liGroup.toggleClass( liGroup.setAttribute('data-groupkey', groupKey);
liGroup.classList.toggle(
'collapsed', 'collapsed',
vAPI.localStorage.getItem('collapseGroup' + (i + 1)) === 'y' vAPI.localStorage.getItem('collapseGroup' + (i + 1)) === 'y'
); );
ulLists.append(liGroup); if ( liGroup.parentElement === null ) {
ulLists.appendChild(liGroup);
}
delete groups[groupKey]; delete groups[groupKey];
} }
// For all groups not covered above (if any left) // For all groups not covered above (if any left)
groupKeys = Object.keys(groups); groupKeys = Object.keys(groups);
for ( i = 0; i < groupKeys.length; i++ ) { for ( i = 0; i < groupKeys.length; i++ ) {
groupKey = groupKeys[i]; groupKey = groupKeys[i];
ulLists.append(liFromListGroup(groupKey, groups[groupKey])); ulLists.appendChild(liFromListGroup(groupKey, groups[groupKey]));
} }
uDom('#lists .listEntries .listEntry.discard').remove();
uDom('#buttonUpdate').toggleClass('disabled', document.querySelector('#lists .listEntry.obsolete') === null);
uDom('#autoUpdate').prop('checked', listDetails.autoUpdate === true);
uDom('#parseCosmeticFilters').prop('checked', listDetails.parseCosmeticFilters === true);
uDom('#ignoreGenericCosmeticFilters').prop('checked', listDetails.ignoreGenericCosmeticFilters === true);
uDom('#listsOfBlockedHostsPrompt').text( uDom('#listsOfBlockedHostsPrompt').text(
vAPI.i18n('3pListsOfBlockedHostsPrompt') vAPI.i18n('3pListsOfBlockedHostsPrompt')
.replace('{{netFilterCount}}', renderNumber(details.netFilterCount)) .replace('{{netFilterCount}}', renderNumber(details.netFilterCount))
.replace('{{cosmeticFilterCount}}', renderNumber(details.cosmeticFilterCount)) .replace('{{cosmeticFilterCount}}', renderNumber(details.cosmeticFilterCount))
); );
uDom('#autoUpdate').prop('checked', listDetails.autoUpdate === true);
uDom('#parseCosmeticFilters').prop('checked', listDetails.parseCosmeticFilters === true); // Compute a hash of the lists currently enabled in memory.
uDom('#ignoreGenericCosmeticFilters').prop('checked', listDetails.ignoreGenericCosmeticFilters === true); var selectedListsBefore = [];
for ( var key in listDetails.current ) {
if ( listDetails.current[key].off !== true ) {
selectedListsBefore.push(key);
}
}
selectedListsHashBefore = selectedListsBefore.sort().join();
renderWidgets(); renderWidgets();
renderBusyOverlay(details.manualUpdate, details.manualUpdateProgress);
}; };
messaging.send('dashboard', { what: 'getLists' }, onListsReceived); messaging.send('dashboard', { what: 'getLists' }, onListsReceived);
@ -271,33 +272,22 @@ var renderFilterLists = function() {
/******************************************************************************/ /******************************************************************************/
// Progress must be normalized to [0, 1], or can be undefined.
var renderBusyOverlay = function(state, progress) {
progress = progress || {};
var showProgress = typeof progress.value === 'number';
if ( showProgress ) {
uDom('#busyOverlay > div:nth-of-type(2) > div:first-child').css(
'width',
(progress.value * 100).toFixed(1) + '%'
);
var text = progress.text || '';
if ( text !== '' ) {
uDom('#busyOverlay > div:nth-of-type(2) > div:last-child').text(text);
}
}
uDom('#busyOverlay > div:nth-of-type(2)').css('display', showProgress ? '' : 'none');
uDom('body').toggleClass('busy', !!state);
};
/******************************************************************************/
// This is to give a visual hint that the selection of blacklists has changed. // This is to give a visual hint that the selection of blacklists has changed.
var renderWidgets = function() { var renderWidgets = function() {
uDom('#buttonApply').toggleClass('disabled', !listsSelectionChanged()); uDom('#buttonApply').toggleClass('disabled', !listsSelectionChanged());
uDom('#buttonUpdate').toggleClass('disabled', !listsContentChanged()); uDom('#buttonPurgeAll').toggleClass('disabled', document.querySelector('#lists .listEntry.cached') === null);
uDom('#buttonPurgeAll').toggleClass('disabled', !hasCachedContent); uDom('#buttonUpdate').toggleClass('disabled', document.querySelector('#lists .listEntry.obsolete') === null);
};
/******************************************************************************/
var updateAssetStatus = function(details) {
var li = uDom('#lists .listEntry[data-listkey="' + details.key + '"]');
li.toggleClass('obsolete', !details.cached);
li.toggleClass('cached', details.cached);
li.removeClass('updating');
renderWidgets();
}; };
/******************************************************************************/ /******************************************************************************/
@ -307,98 +297,49 @@ var renderWidgets = function() {
var listsSelectionChanged = function() { var listsSelectionChanged = function() {
if ( if (
listDetails.parseCosmeticFilters !== parseCosmeticFilters || listDetails.parseCosmeticFilters !== parseCosmeticFilters ||
listDetails.parseCosmeticFilters && listDetails.ignoreGenericCosmeticFilters !== ignoreGenericCosmeticFilters listDetails.parseCosmeticFilters &&
listDetails.ignoreGenericCosmeticFilters !== ignoreGenericCosmeticFilters
) { ) {
return true; return true;
} }
var selectedListsAfter = [],
if ( cacheWasPurged ) { listEntries = uDom('#lists .listEntry[data-listkey] > input[type="checkbox"]:checked');
return true; for ( var i = 0, n = listEntries.length; i < n; i++ ) {
selectedListsAfter.push(listEntries.at(i).ancestors('.listEntry[data-listkey]').attr('data-listkey'));
} }
var availableLists = listDetails.available; return selectedListsHashBefore !== selectedListsAfter.sort().join();
var currentLists = listDetails.current;
var location, availableOff, currentOff;
// This check existing entries
for ( location in availableLists ) {
if ( availableLists.hasOwnProperty(location) === false ) {
continue;
}
availableOff = availableLists[location].off === true;
currentOff = currentLists[location] === undefined || currentLists[location].off === true;
if ( availableOff !== currentOff ) {
return true;
}
}
// This check removed entries
for ( location in currentLists ) {
if ( currentLists.hasOwnProperty(location) === false ) {
continue;
}
currentOff = currentLists[location].off === true;
availableOff = availableLists[location] === undefined || availableLists[location].off === true;
if ( availableOff !== currentOff ) {
return true;
}
}
return false;
};
/******************************************************************************/
// Return whether content need update.
var listsContentChanged = function() {
return needUpdate;
}; };
/******************************************************************************/ /******************************************************************************/
var onListCheckboxChanged = function() { var onListCheckboxChanged = function() {
var href = uDom(this).parent().descendants('a').first().attr('data-listkey');
if ( typeof href !== 'string' ) {
return;
}
if ( listDetails.available[href] === undefined ) {
return;
}
listDetails.available[href].off = !this.checked;
renderWidgets(); renderWidgets();
}; };
/******************************************************************************/ /******************************************************************************/
var onPurgeClicked = function() { var onPurgeClicked = function() {
var button = uDom(this); var button = uDom(this),
var li = button.parent(); liEntry = button.ancestors('[data-listkey]'),
var href = li.descendants('a').first().attr('data-listkey'); listKey = liEntry.attr('data-listkey');
if ( !href ) { if ( !listKey ) { return; }
return;
}
messaging.send('dashboard', { what: 'purgeCache', path: href }); messaging.send('dashboard', { what: 'purgeCache', assetKey: listKey });
button.remove();
// If the cached version is purged, the installed version must be assumed // If the cached version is purged, the installed version must be assumed
// to be obsolete. // to be obsolete.
// https://github.com/gorhill/uBlock/issues/1733 // https://github.com/gorhill/uBlock/issues/1733
// An external filter list must not be marked as obsolete, they will always // An external filter list must not be marked as obsolete, they will always
// be fetched anyways if there is no cached copy. // be fetched anyways if there is no cached copy.
var entry = listDetails.current && listDetails.current[href]; var entry = listDetails.current && listDetails.current[listKey];
if ( entry && entry.off !== true && /^[a-z]+:\/\//.test(href) === false ) { if ( entry && entry.off !== true ) {
if ( typeof entry.homeURL !== 'string' || entry.homeURL === '' ) { liEntry.addClass('obsolete');
li.descendants('span.status.new').css('display', ''); uDom('#buttonUpdate').removeClass('disabled');
} else {
li.descendants('span.status.obsolete').css('display', '');
}
needUpdate = true;
} }
liEntry.removeClass('cached');
if ( li.descendants('input').first().prop('checked') ) { if ( liEntry.descendants('input').first().prop('checked') ) {
cacheWasPurged = true;
renderWidgets(); renderWidgets();
} }
}; };
@ -419,22 +360,21 @@ var selectFilterLists = function(callback) {
}); });
// Filter lists // Filter lists
var switches = []; var listKeys = [],
var lis = uDom('#lists .listEntry'), li; liEntries = uDom('#lists .listEntry'), liEntry,
var i = lis.length; i = liEntries.length;
while ( i-- ) { while ( i-- ) {
li = lis.at(i); liEntry = liEntries.at(i);
switches.push({ if ( liEntry.descendants('input').first().prop('checked') ) {
location: li.descendants('a').attr('data-listkey'), listKeys.push(liEntry.attr('data-listkey'));
off: li.descendants('input').prop('checked') === false }
});
} }
messaging.send( messaging.send(
'dashboard', 'dashboard',
{ {
what: 'selectFilterLists', what: 'selectFilterLists',
switches: switches keys: listKeys
}, },
callback callback
); );
@ -444,49 +384,34 @@ var selectFilterLists = function(callback) {
var buttonApplyHandler = function() { var buttonApplyHandler = function() {
uDom('#buttonApply').removeClass('enabled'); uDom('#buttonApply').removeClass('enabled');
renderBusyOverlay(true);
var onSelectionDone = function() { var onSelectionDone = function() {
messaging.send('dashboard', { what: 'reloadAllFilters' }); messaging.send('dashboard', { what: 'reloadAllFilters' });
}; };
selectFilterLists(onSelectionDone); selectFilterLists(onSelectionDone);
cacheWasPurged = false;
}; };
/******************************************************************************/ /******************************************************************************/
var buttonUpdateHandler = function() { var buttonUpdateHandler = function() {
uDom('#buttonUpdate').removeClass('enabled'); var onSelectionDone = function() {
uDom('#lists .listEntry.obsolete').addClass('updating');
if ( needUpdate ) { messaging.send('dashboard', { what: 'forceUpdateAssets' });
renderBusyOverlay(true); };
selectFilterLists(onSelectionDone);
var onSelectionDone = function() {
messaging.send('dashboard', { what: 'forceUpdateAssets' });
};
selectFilterLists(onSelectionDone);
cacheWasPurged = false;
}
}; };
/******************************************************************************/ /******************************************************************************/
var buttonPurgeAllHandler = function() { var buttonPurgeAllHandler = function(ev) {
uDom('#buttonPurgeAll').removeClass('enabled'); uDom('#buttonPurgeAll').removeClass('enabled');
messaging.send(
renderBusyOverlay(true); 'dashboard',
{
var onCompleted = function() { what: 'purgeAllCaches',
cacheWasPurged = true; hard: ev.ctrlKey && ev.shiftKey
renderFilterLists(); },
}; renderFilterLists
);
messaging.send('dashboard', { what: 'purgeAllCaches' }, onCompleted);
}; };
/******************************************************************************/ /******************************************************************************/
@ -562,7 +487,7 @@ var groupEntryClickHandler = function() {
/******************************************************************************/ /******************************************************************************/
var getCloudData = function() { var toCloudData = function() {
var bin = { var bin = {
parseCosmeticFilters: uDom.nodeFromId('parseCosmeticFilters').checked, parseCosmeticFilters: uDom.nodeFromId('parseCosmeticFilters').checked,
ignoreGenericCosmeticFilters: uDom.nodeFromId('ignoreGenericCosmeticFilters').checked, ignoreGenericCosmeticFilters: uDom.nodeFromId('ignoreGenericCosmeticFilters').checked,
@ -570,24 +495,22 @@ var getCloudData = function() {
externalLists: externalLists externalLists: externalLists
}; };
var lis = uDom('#lists .listEntry'), li; var liEntries = uDom('#lists .listEntry'), liEntry;
var i = lis.length; var i = liEntries.length;
while ( i-- ) { while ( i-- ) {
li = lis.at(i); liEntry = liEntries.at(i);
if ( li.descendants('input').prop('checked') ) { if ( liEntry.descendants('input').prop('checked') ) {
bin.selectedLists.push(li.descendants('a').attr('data-listkey')); bin.selectedLists.push(liEntry.attr('data-listkey'));
} }
} }
return bin; return bin;
}; };
var setCloudData = function(data, append) { var fromCloudData = function(data, append) {
if ( typeof data !== 'object' || data === null ) { if ( typeof data !== 'object' || data === null ) { return; }
return;
}
var elem, checked; var elem, checked, i, n;
elem = uDom.nodeFromId('parseCosmeticFilters'); elem = uDom.nodeFromId('parseCosmeticFilters');
checked = data.parseCosmeticFilters === true || append && elem.checked; checked = data.parseCosmeticFilters === true || append && elem.checked;
@ -597,30 +520,34 @@ var setCloudData = function(data, append) {
checked = data.ignoreGenericCosmeticFilters === true || append && elem.checked; checked = data.ignoreGenericCosmeticFilters === true || append && elem.checked;
elem.checked = listDetails.ignoreGenericCosmeticFilters = checked; elem.checked = listDetails.ignoreGenericCosmeticFilters = checked;
var lis = uDom('#lists .listEntry'), li, listKey; var listKey;
var i = lis.length; for ( i = 0, n = data.selectedLists.length; i < n; i++ ) {
while ( i-- ) { listKey = data.selectedLists[i];
li = lis.at(i); if ( listDetails.aliases[listKey] ) {
elem = li.descendants('input'); data.selectedLists[i] = listDetails.aliases[listKey];
listKey = li.descendants('a').attr('data-listkey'); }
checked = data.selectedLists.indexOf(listKey) !== -1 || }
append && elem.prop('checked'); var selectedSet = new Set(data.selectedLists),
elem.prop('checked', checked); listEntries = uDom('#lists .listEntry'),
listDetails.available[listKey].off = !checked; listEntry, input;
for ( i = 0, n = listEntries.length; i < n; i++ ) {
listEntry = listEntries.at(i);
listKey = listEntry.attr('data-listkey');
input = listEntry.descendants('input').first();
if ( append && input.prop('checked') ) { continue; }
input.prop('checked', selectedSet.has(listKey) );
} }
elem = uDom.nodeFromId('externalLists'); elem = uDom.nodeFromId('externalLists');
if ( !append ) { if ( !append ) { elem.value = ''; }
elem.value = '';
}
elem.value += data.externalLists || ''; elem.value += data.externalLists || '';
renderWidgets(); renderWidgets();
externalListsChangeHandler(); externalListsChangeHandler();
}; };
self.cloud.onPush = getCloudData; self.cloud.onPush = toCloudData;
self.cloud.onPull = setCloudData; self.cloud.onPull = fromCloudData;
/******************************************************************************/ /******************************************************************************/

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
uBlock Origin - a browser extension to block requests. uBlock Origin - a browser extension to block requests.
Copyright (C) 2014-2016 Raymond Hill Copyright (C) 2014-2017 Raymond Hill
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -19,20 +19,16 @@
Home: https://github.com/gorhill/uBlock Home: https://github.com/gorhill/uBlock
*/ */
/* exported µBlock */
'use strict'; 'use strict';
/******************************************************************************/ /******************************************************************************/
var µBlock = (function() { var µBlock = (function() { // jshint ignore:line
/******************************************************************************/ /******************************************************************************/
var oneSecond = 1000; var oneSecond = 1000;
var oneMinute = 60 * oneSecond; var oneMinute = 60 * oneSecond;
var oneHour = 60 * oneMinute;
// var oneDay = 24 * oneHour;
/******************************************************************************/ /******************************************************************************/
@ -71,8 +67,12 @@ return {
}, },
hiddenSettingsDefault: { hiddenSettingsDefault: {
assetFetchTimeout: 30,
autoUpdateAssetFetchPeriod: 120,
autoUpdatePeriod: 7,
ignoreRedirectFilters: false, ignoreRedirectFilters: false,
ignoreScriptInjectFilters: false, ignoreScriptInjectFilters: false,
manualUpdateAssetFetchPeriod: 2000,
popupFontSize: 'unset', popupFontSize: 'unset',
suspendTabsUntilReady: false suspendTabsUntilReady: false
}, },
@ -119,92 +119,15 @@ return {
lastBackupTime: 0 lastBackupTime: 0
}, },
// EasyList, EasyPrivacy and many others have an 4-day update period, // Allows to fully customize uBO's assets, typically set through admin
// as per list headers. // settings. The content of 'assets.json' will also tell which filter
updateAssetsEvery: 97 * oneHour, // lists to enable by default when uBO is first installed.
projectServerRoot: 'https://raw.githubusercontent.com/gorhill/uBlock/master/', assetsBootstrapLocation: 'assets/assets.json',
userFiltersPath: 'assets/user/filters.txt',
pslPath: 'assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat',
// permanent lists userFiltersPath: 'user-filters',
permanentLists: { pslAssetKey: 'public_suffix_list.dat',
// User
'assets/user/filters.txt': {
group: 'default'
},
// uBlock
'assets/ublock/filters.txt': {
title: 'uBlock filters',
group: 'default'
},
'assets/ublock/privacy.txt': {
title: 'uBlock filters Privacy',
group: 'default'
},
'assets/ublock/unbreak.txt': {
title: 'uBlock filters Unbreak',
group: 'default'
},
'assets/ublock/badware.txt': {
title: 'uBlock filters Badware risks',
group: 'default',
supportURL: 'https://github.com/gorhill/uBlock/wiki/Badware-risks',
instructionURL: 'https://github.com/gorhill/uBlock/wiki/Badware-risks'
},
'assets/ublock/experimental.txt': {
title: 'uBlock filters Experimental',
group: 'default',
off: true,
supportURL: 'https://github.com/gorhill/uBlock/wiki/Experimental-filters',
instructionURL: 'https://github.com/gorhill/uBlock/wiki/Experimental-filters'
}
},
// current lists availableFilterLists: {},
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.dk/block.csv",
"https://adblock.schack.dk/block.txt": "https://adblock.dk/block.csv",
"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://raw.githubusercontent.com/MajkiIT/polish-ads-filter/master/polish-adblock-filters/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": "",
"https://iadb.azurewebsites.net/Finland_adb.txt": "http://adb.juvander.net/Finland_adb.txt",
"https://www.certyficate.it/adblock/adblock.txt": "https://raw.githubusercontent.com/MajkiIT/polish-ads-filter/master/polish-adblock-filters/adblock.txt",
"https://raw.githubusercontent.com/heradhis/indonesianadblockrules/master/subscriptions/abpindo.txt": "https://raw.githubusercontent.com/ABPindo/indonesianadblockrules/master/subscriptions/abpindo.txt"
},
selfieAfter: 23 * oneMinute, selfieAfter: 23 * oneMinute,

View File

@ -19,15 +19,13 @@
Home: https://github.com/gorhill/uBlock Home: https://github.com/gorhill/uBlock
*/ */
/* global µBlock */ 'use strict';
/******************************************************************************/ /******************************************************************************/
/******************************************************************************/ /******************************************************************************/
µBlock.logger = (function() { µBlock.logger = (function() {
'use strict';
/******************************************************************************/ /******************************************************************************/
/******************************************************************************/ /******************************************************************************/

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
uBlock Origin - a browser extension to block requests. uBlock Origin - a browser extension to block requests.
Copyright (C) 2014-2016 Raymond Hill Copyright (C) 2014-2017 Raymond Hill
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -77,7 +77,7 @@ var onMessage = function(request, sender, callback) {
return; return;
case 'reloadAllFilters': case 'reloadAllFilters':
µb.reloadAllFilters(callback); µb.loadFilterLists();
return; return;
case 'scriptlet': case 'scriptlet':
@ -121,7 +121,8 @@ var onMessage = function(request, sender, callback) {
break; break;
case 'forceUpdateAssets': case 'forceUpdateAssets':
µb.assetUpdater.force(); µb.scheduleAssetUpdater(0);
µb.assets.updateStart({ delay: µb.hiddenSettings.manualUpdateAssetFetchPeriod || 2000 });
break; break;
case 'getAppData': case 'getAppData':
@ -160,7 +161,7 @@ var onMessage = function(request, sender, callback) {
break; break;
case 'selectFilterLists': case 'selectFilterLists':
µb.selectFilterLists(request.switches); µb.saveSelectedFilterLists(request.keys, request.append);
break; break;
case 'setWhitelist': case 'setWhitelist':
@ -753,7 +754,7 @@ var backupUserData = function(callback) {
timeStamp: Date.now(), timeStamp: Date.now(),
version: vAPI.app.version, version: vAPI.app.version,
userSettings: µb.userSettings, userSettings: µb.userSettings,
filterLists: {}, selectedFilterLists: [],
hiddenSettingsString: µb.stringFromHiddenSettings(), hiddenSettingsString: µb.stringFromHiddenSettings(),
netWhitelist: µb.stringFromWhitelist(µb.netWhitelist), netWhitelist: µb.stringFromWhitelist(µb.netWhitelist),
dynamicFilteringString: µb.permanentFirewall.toString(), dynamicFilteringString: µb.permanentFirewall.toString(),
@ -762,8 +763,17 @@ var backupUserData = function(callback) {
userFilters: '' userFilters: ''
}; };
var onSelectedListsReady = function(filterLists) { var onSelectedListsReady = function(selectedFilterLists) {
userData.filterLists = filterLists; userData.selectedFilterLists = selectedFilterLists;
// TODO(seamless migration):
// The following is strictly for convenience, to be minimally
// forward-compatible. This will definitely be removed in the
// short term, as I do not expect the need to install an older
// version of uBO to ever be needed beyond the short term.
// >>>>>>>>
userData.filterLists = µb.oldDataFromNewListKeys(selectedFilterLists);
// <<<<<<<<
var filename = vAPI.i18n('aboutBackupFilename') var filename = vAPI.i18n('aboutBackupFilename')
.replace('{{datetime}}', µb.dateNowToSensibleString()) .replace('{{datetime}}', µb.dateNowToSensibleString())
@ -773,17 +783,15 @@ var backupUserData = function(callback) {
'url': 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(userData, null, ' ')), 'url': 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(userData, null, ' ')),
'filename': filename 'filename': filename
}); });
µb.restoreBackupSettings.lastBackupFile = filename; µb.restoreBackupSettings.lastBackupFile = filename;
µb.restoreBackupSettings.lastBackupTime = Date.now(); µb.restoreBackupSettings.lastBackupTime = Date.now();
vAPI.storage.set(µb.restoreBackupSettings); vAPI.storage.set(µb.restoreBackupSettings);
getLocalData(callback); getLocalData(callback);
}; };
var onUserFiltersReady = function(details) { var onUserFiltersReady = function(details) {
userData.userFilters = details.content; userData.userFilters = details.content;
µb.extractSelectedFilterLists(onSelectedListsReady); µb.loadSelectedFilterLists(onSelectedListsReady);
}; };
µb.assets.get(µb.userFiltersPath, onUserFiltersReady); µb.assets.get(µb.userFiltersPath, onUserFiltersReady);
@ -791,32 +799,32 @@ var backupUserData = function(callback) {
var restoreUserData = function(request) { var restoreUserData = function(request) {
var userData = request.userData; var userData = request.userData;
var countdown = 8;
var onCountdown = function() {
countdown -= 1;
if ( countdown === 0 ) {
vAPI.app.restart();
}
};
var onAllRemoved = function() { var onAllRemoved = function() {
// Be sure to adjust `countdown` if adding/removing anything below
µb.keyvalSetOne('version', userData.version);
µBlock.saveLocalSettings(); µBlock.saveLocalSettings();
vAPI.storage.set(userData.userSettings, onCountdown); vAPI.storage.set(userData.userSettings);
µb.keyvalSetOne('remoteBlacklists', userData.filterLists, onCountdown);
µb.hiddenSettingsFromString(userData.hiddenSettingsString || ''); µb.hiddenSettingsFromString(userData.hiddenSettingsString || '');
µb.keyvalSetOne('netWhitelist', userData.netWhitelist || '', onCountdown);
µb.keyvalSetOne('dynamicFilteringString', userData.dynamicFilteringString || '', onCountdown);
µb.keyvalSetOne('urlFilteringString', userData.urlFilteringString || '', onCountdown);
µb.keyvalSetOne('hostnameSwitchesString', userData.hostnameSwitchesString || '', onCountdown);
µb.assets.put(µb.userFiltersPath, userData.userFilters, onCountdown);
vAPI.storage.set({ vAPI.storage.set({
netWhitelist: userData.netWhitelist || '',
dynamicFilteringString: userData.dynamicFilteringString || '',
urlFilteringString: userData.urlFilteringString || '',
hostnameSwitchesString: userData.hostnameSwitchesString || '',
lastRestoreFile: request.file || '', lastRestoreFile: request.file || '',
lastRestoreTime: Date.now(), lastRestoreTime: Date.now(),
lastBackupFile: '', lastBackupFile: '',
lastBackupTime: 0 lastBackupTime: 0
}, onCountdown); });
µb.assets.put(µb.userFiltersPath, userData.userFilters);
// 'filterLists' is available up to uBO v1.10.4, not beyond.
// 'selectedFilterLists' is available from uBO v1.11 and beyond.
if ( Array.isArray(userData.selectedFilterLists) ) {
µb.saveSelectedFilterLists(userData.selectedFilterLists);
} else if ( userData.filterLists instanceof Object ) {
µb.saveSelectedFilterLists(µb.newListKeysFromOldData(userData.filterLists));
}
vAPI.app.restart();
}; };
// https://github.com/chrisaljoudi/uBlock/issues/1102 // https://github.com/chrisaljoudi/uBlock/issues/1102
@ -848,9 +856,7 @@ var prepListEntries = function(entries) {
var µburi = µb.URI; var µburi = µb.URI;
var entry, hn; var entry, hn;
for ( var k in entries ) { for ( var k in entries ) {
if ( entries.hasOwnProperty(k) === false ) { if ( entries.hasOwnProperty(k) === false ) { continue; }
continue;
}
entry = entries[k]; entry = entries[k];
if ( typeof entry.supportURL === 'string' && entry.supportURL !== '' ) { if ( typeof entry.supportURL === 'string' && entry.supportURL !== '' ) {
entry.supportName = µburi.hostnameFromURI(entry.supportURL); entry.supportName = µburi.hostnameFromURI(entry.supportURL);
@ -869,16 +875,14 @@ var getLists = function(callback) {
cache: null, cache: null,
parseCosmeticFilters: µb.userSettings.parseAllABPHideFilters, parseCosmeticFilters: µb.userSettings.parseAllABPHideFilters,
cosmeticFilterCount: µb.cosmeticFilteringEngine.getFilterCount(), cosmeticFilterCount: µb.cosmeticFilteringEngine.getFilterCount(),
current: µb.remoteBlacklists, current: µb.availableFilterLists,
ignoreGenericCosmeticFilters: µb.userSettings.ignoreGenericCosmeticFilters, ignoreGenericCosmeticFilters: µb.userSettings.ignoreGenericCosmeticFilters,
manualUpdate: false,
netFilterCount: µb.staticNetFilteringEngine.getFilterCount(), netFilterCount: µb.staticNetFilteringEngine.getFilterCount(),
userFiltersPath: µb.userFiltersPath userFiltersPath: µb.userFiltersPath,
aliases: µb.assets.listKeyAliases
}; };
var onMetadataReady = function(entries) { var onMetadataReady = function(entries) {
r.cache = entries; r.cache = entries;
r.manualUpdate = µb.assetUpdater.manualUpdate;
r.manualUpdateProgress = µb.assetUpdater.manualUpdateProgress;
prepListEntries(r.cache); prepListEntries(r.cache);
callback(r); callback(r);
}; };
@ -952,9 +956,6 @@ var onMessage = function(request, sender, callback) {
case 'getLocalData': case 'getLocalData':
return getLocalData(callback); return getLocalData(callback);
case 'purgeAllCaches':
return µb.assets.purgeAll(callback);
case 'readUserFilters': case 'readUserFilters':
return µb.loadUserFilters(callback); return µb.loadUserFilters(callback);
@ -973,8 +974,18 @@ var onMessage = function(request, sender, callback) {
response = getRules(); response = getRules();
break; break;
case 'purgeAllCaches':
if ( request.hard ) {
µb.assets.remove(/./);
} else {
µb.assets.remove(/compiled\//);
µb.assets.purge(/./);
}
break;
case 'purgeCache': case 'purgeCache':
µb.assets.purgeCacheableAsset(request.path); µb.assets.purge(request.assetKey);
µb.assets.remove('compiled/' + request.assetKey);
break; break;
case 'readHiddenSettings': case 'readHiddenSettings':

View File

@ -402,27 +402,15 @@ RedirectEngine.prototype.resourceContentFromName = function(name, mime) {
// TODO: combine same key-redirect pairs into a single regex. // TODO: combine same key-redirect pairs into a single regex.
RedirectEngine.prototype.resourcesFromString = function(text) { RedirectEngine.prototype.resourcesFromString = function(text) {
var textEnd = text.length; var line, fields, encoded,
var lineBeg = 0, lineEnd; reNonEmptyLine = /\S/,
var line, fields, encoded; lineIter = new µBlock.LineIterator(text);
var reNonEmptyLine = /\S/;
this.resources = new Map(); this.resources = new Map();
while ( lineBeg < textEnd ) { while ( lineIter.eot() === false ) {
lineEnd = text.indexOf('\n', lineBeg); line = lineIter.next();
if ( lineEnd < 0 ) { if ( line.startsWith('#') ) { continue; }
lineEnd = text.indexOf('\r', lineBeg);
if ( lineEnd < 0 ) {
lineEnd = textEnd;
}
}
line = text.slice(lineBeg, lineEnd);
lineBeg = lineEnd + 1;
if ( line.startsWith('#') ) {
continue;
}
if ( fields === undefined ) { if ( fields === undefined ) {
fields = line.trim().split(/\s+/); fields = line.trim().split(/\s+/);

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
uBlock - a browser extension to block requests. uBlock Origin - a browser extension to block requests.
Copyright (C) 2015 Raymond Hill Copyright (C) 2015-2017 Raymond Hill
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -43,8 +43,8 @@ var fromNetFilter = function(details) {
var lists = []; var lists = [];
var compiledFilter = details.compiledFilter; var compiledFilter = details.compiledFilter;
var entry, content, pos, c; var entry, content, pos, c;
for ( var path in listEntries ) { for ( var assetKey in listEntries ) {
entry = listEntries[path]; entry = listEntries[assetKey];
if ( entry === undefined ) { if ( entry === undefined ) {
continue; continue;
} }
@ -173,11 +173,11 @@ var fromCosmeticFilter = function(details) {
); );
} }
var re, path, entry; var re, assetKey, entry;
for ( var candidate in candidates ) { for ( var candidate in candidates ) {
re = candidates[candidate]; re = candidates[candidate];
for ( path in listEntries ) { for ( assetKey in listEntries ) {
entry = listEntries[path]; entry = listEntries[assetKey];
if ( entry === undefined ) { if ( entry === undefined ) {
continue; continue;
} }
@ -206,7 +206,7 @@ var reHighMedium = /^\[href\^="https?:\/\/([^"]{8})[^"]*"\]$/;
/******************************************************************************/ /******************************************************************************/
onmessage = function(e) { onmessage = function(e) { // jshint ignore:line
var msg = e.data; var msg = e.data;
switch ( msg.what ) { switch ( msg.what ) {
@ -215,7 +215,7 @@ onmessage = function(e) {
break; break;
case 'setList': case 'setList':
listEntries[msg.details.path] = msg.details; listEntries[msg.details.assetKey] = msg.details;
break; break;
case 'fromNetFilter': case 'fromNetFilter':

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
uBlock - a browser extension to block requests. uBlock Origin - a browser extension to block requests.
Copyright (C) 2015 Raymond Hill Copyright (C) 2015-2017 Raymond Hill
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -19,14 +19,12 @@
Home: https://github.com/gorhill/uBlock Home: https://github.com/gorhill/uBlock
*/ */
/* global µBlock */ 'use strict';
/******************************************************************************/ /******************************************************************************/
µBlock.staticFilteringReverseLookup = (function() { µBlock.staticFilteringReverseLookup = (function() {
'use strict';
/******************************************************************************/ /******************************************************************************/
var worker = null; var worker = null;
@ -77,16 +75,16 @@ var initWorker = function(callback) {
var countdown = 0; var countdown = 0;
var onListLoaded = function(details) { var onListLoaded = function(details) {
var entry = entries[details.path]; var entry = entries[details.assetKey];
// https://github.com/gorhill/uBlock/issues/536 // https://github.com/gorhill/uBlock/issues/536
// Use path string when there is no filter list title. // Use assetKey when there is no filter list title.
worker.postMessage({ worker.postMessage({
what: 'setList', what: 'setList',
details: { details: {
path: details.path, assetKey: details.assetKey,
title: entry.title || details.path, title: entry.title || details.assetKey,
supportURL: entry.supportURL, supportURL: entry.supportURL,
content: details.content content: details.content
} }
@ -99,18 +97,18 @@ var initWorker = function(callback) {
}; };
var µb = µBlock; var µb = µBlock;
var path, entry; var listKey, entry;
for ( path in µb.remoteBlacklists ) { for ( listKey in µb.availableFilterLists ) {
if ( µb.remoteBlacklists.hasOwnProperty(path) === false ) { if ( µb.availableFilterLists.hasOwnProperty(listKey) === false ) {
continue; continue;
} }
entry = µb.remoteBlacklists[path]; entry = µb.availableFilterLists[listKey];
if ( entry.off === true ) { if ( entry.off === true ) { continue; }
continue; entries[listKey] = {
} title: listKey !== µb.userFiltersPath ?
entries[path] = { entry.title :
title: path !== µb.userFiltersPath ? entry.title : vAPI.i18n('1pPageName'), vAPI.i18n('1pPageName'),
supportURL: entry.supportURL || '' supportURL: entry.supportURL || ''
}; };
countdown += 1; countdown += 1;
@ -121,8 +119,8 @@ var initWorker = function(callback) {
return; return;
} }
for ( path in entries ) { for ( listKey in entries ) {
µb.getCompiledFilterList(path, onListLoaded); µb.getCompiledFilterList(listKey, onListLoaded);
} }
}; };

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
uBlock Origin - a browser extension to block requests. uBlock Origin - a browser extension to block requests.
Copyright (C) 2015-2016 Raymond Hill Copyright (C) 2015-2017 Raymond Hill
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -21,6 +21,8 @@
/* global vAPI, HTMLDocument */ /* global vAPI, HTMLDocument */
'use strict';
/******************************************************************************/ /******************************************************************************/
// Injected into specific web pages, those which have been pre-selected // Injected into specific web pages, those which have been pre-selected
@ -30,8 +32,6 @@
(function() { (function() {
'use strict';
/******************************************************************************/ /******************************************************************************/
// https://github.com/chrisaljoudi/uBlock/issues/464 // https://github.com/chrisaljoudi/uBlock/issues/464
@ -100,7 +100,8 @@ var onAbpLinkClicked = function(ev) {
'scriptlets', 'scriptlets',
{ {
what: 'selectFilterLists', what: 'selectFilterLists',
switches: [ { location: location, off: false } ] keys: [ location ],
append: true
}, },
onListsSelectionDone onListsSelectionDone
); );

View File

@ -56,7 +56,10 @@ var handleImportFilePicker = function() {
if ( typeof userData.netWhitelist !== 'string' ) { if ( typeof userData.netWhitelist !== 'string' ) {
throw 'Invalid'; throw 'Invalid';
} }
if ( typeof userData.filterLists !== 'object' ) { if (
typeof userData.filterLists !== 'object' &&
Array.isArray(userData.selectedFilterLists) === false
) {
throw 'Invalid'; throw 'Invalid';
} }
} }

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
uBlock Origin - a browser extension to block requests. uBlock Origin - a browser extension to block requests.
Copyright (C) 2014-2016 Raymond Hill Copyright (C) 2014-2017 Raymond Hill
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -39,7 +39,7 @@ var µb = µBlock;
vAPI.app.onShutdown = function() { vAPI.app.onShutdown = function() {
µb.staticFilteringReverseLookup.shutdown(); µb.staticFilteringReverseLookup.shutdown();
µb.assetUpdater.shutdown(); µb.assets.updateStop();
µb.staticNetFilteringEngine.reset(); µb.staticNetFilteringEngine.reset();
µb.cosmeticFilteringEngine.reset(); µb.cosmeticFilteringEngine.reset();
µb.sessionFirewall.reset(); µb.sessionFirewall.reset();
@ -58,14 +58,8 @@ vAPI.app.onShutdown = function() {
var onAllReady = function() { var onAllReady = function() {
// https://github.com/chrisaljoudi/uBlock/issues/184 // https://github.com/chrisaljoudi/uBlock/issues/184
// Check for updates not too far in the future. // Check for updates not too far in the future.
µb.assetUpdater.onStart.addEventListener(µb.updateStartHandler.bind(µb)); µb.assets.addObserver(µb.assetObserver.bind(µb));
µb.assetUpdater.onCompleted.addEventListener(µb.updateCompleteHandler.bind(µb)); µb.scheduleAssetUpdater(µb.userSettings.autoUpdate ? 7 * 60 * 1000 : 0);
µb.assetUpdater.onAssetUpdated.addEventListener(µb.assetUpdatedHandler.bind(µb));
µb.assets.onAssetRemoved.addListener(µb.assetCacheRemovedHandler.bind(µb));
// Important: remove barrier to remote fetching, this was useful only
// for launch time.
µb.assets.remoteFetchBarrier -= 1;
// vAPI.cloud is optional. // vAPI.cloud is optional.
if ( µb.cloudStorageSupported ) { if ( µb.cloudStorageSupported ) {
@ -129,7 +123,7 @@ var onSelfieReady = function(selfie) {
return false; return false;
} }
µb.remoteBlacklists = selfie.filterLists; µb.availableFilterLists = selfie.availableFilterLists;
µb.staticNetFilteringEngine.fromSelfie(selfie.staticNetFilteringEngine); µb.staticNetFilteringEngine.fromSelfie(selfie.staticNetFilteringEngine);
µb.redirectEngine.fromSelfie(selfie.redirectEngine); µb.redirectEngine.fromSelfie(selfie.redirectEngine);
µb.cosmeticFilteringEngine.fromSelfie(selfie.cosmeticFilteringEngine); µb.cosmeticFilteringEngine.fromSelfie(selfie.cosmeticFilteringEngine);
@ -157,12 +151,6 @@ var onUserSettingsReady = function(fetched) {
fromFetch(userSettings, fetched); fromFetch(userSettings, fetched);
// https://github.com/chrisaljoudi/uBlock/issues/426
// Important: block remote fetching for when loading assets at launch
// time.
µb.assets.autoUpdate = userSettings.autoUpdate;
µb.assets.autoUpdateDelay = µb.updateAssetsEvery;
if ( µb.privacySettingsSupported ) { if ( µb.privacySettingsSupported ) {
vAPI.browserSettings.set({ vAPI.browserSettings.set({
'hyperlinkAuditing': !userSettings.hyperlinkAuditingDisabled, 'hyperlinkAuditing': !userSettings.hyperlinkAuditingDisabled,
@ -192,7 +180,7 @@ var onUserSettingsReady = function(fetched) {
var onSystemSettingsReady = function(fetched) { var onSystemSettingsReady = function(fetched) {
var mustSaveSystemSettings = false; var mustSaveSystemSettings = false;
if ( fetched.compiledMagic !== µb.systemSettings.compiledMagic ) { if ( fetched.compiledMagic !== µb.systemSettings.compiledMagic ) {
µb.assets.purge(/^cache:\/\/compiled-/); µb.assets.remove(/^compiled\//);
mustSaveSystemSettings = true; mustSaveSystemSettings = true;
} }
if ( fetched.selfieMagic !== µb.systemSettings.selfieMagic ) { if ( fetched.selfieMagic !== µb.systemSettings.selfieMagic ) {
@ -254,9 +242,6 @@ var fromFetch = function(to, fetched) {
/******************************************************************************/ /******************************************************************************/
var onAdminSettingsRestored = function() { var onAdminSettingsRestored = function() {
// Forbid remote fetching of assets
µb.assets.remoteFetchBarrier += 1;
var fetchableProps = { var fetchableProps = {
'compiledMagic': '', 'compiledMagic': '',
'dynamicFilteringString': 'behind-the-scene * 3p noop\nbehind-the-scene * 3p-frame noop', 'dynamicFilteringString': 'behind-the-scene * 3p noop\nbehind-the-scene * 3p-frame noop',

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
uBlock Origin - a browser extension to block requests. uBlock Origin - a browser extension to block requests.
Copyright (C) 2014-2016 Raymond Hill Copyright (C) 2014-2017 Raymond Hill
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -317,6 +317,9 @@ var reInvalidHostname = /[^a-z0-9.\-\[\]:]/,
// Pre-change // Pre-change
switch ( name ) { switch ( name ) {
case 'externalLists':
this.changeExternalFilterLists(us.externalLists, value);
break;
case 'largeMediaSize': case 'largeMediaSize':
if ( typeof value !== 'number' ) { if ( typeof value !== 'number' ) {
value = parseInt(value, 10) || 0; value = parseInt(value, 10) || 0;
@ -340,6 +343,9 @@ var reInvalidHostname = /[^a-z0-9.\-\[\]:]/,
us.dynamicFilteringEnabled = true; us.dynamicFilteringEnabled = true;
} }
break; break;
case 'autoUpdate':
this.scheduleAssetUpdater(value ? 7 * 60 * 1000 : 0);
break;
case 'collapseBlocked': case 'collapseBlocked':
if ( value === false ) { if ( value === false ) {
this.cosmeticFilteringEngine.removeFromSelectorCache('*', 'net'); this.cosmeticFilteringEngine.removeFromSelectorCache('*', 'net');

View File

@ -24,8 +24,6 @@ cp -R ../uAssets/thirdparties/www.malwaredomainlist.com $DES/thirdparti
mkdir $DES/ublock mkdir $DES/ublock
cp -R ../uAssets/filters/* $DES/ublock/ cp -R ../uAssets/filters/* $DES/ublock/
cp -R ./assets/ublock/filter-lists.json $DES/ublock/ cp -R ./assets/assets.json $DES/
cp ../uAssets/checksums/ublock0.txt $DES/checksums.txt
echo "done." echo "done."

View File

@ -5,7 +5,11 @@
echo "*** uBlock0.chromium: Creating web store package" echo "*** uBlock0.chromium: Creating web store package"
echo "*** uBlock0.chromium: Copying files" echo "*** uBlock0.chromium: Copying files"
DES=dist/build/uBlock0.chromium if [ "$1" = experimental ]; then
DES=dist/build/experimental/uBlock0.chromium
else
DES=dist/build/uBlock0.chromium
fi
rm -rf $DES rm -rf $DES
mkdir -p $DES mkdir -p $DES