@browserless.io/browserless 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/README.md +55 -36
- package/build/config.d.ts +2 -2
- package/build/config.js +3 -3
- package/build/data/classes.json +1 -1
- package/build/data/selectors.json +1 -1
- package/build/http.d.ts +1 -0
- package/build/http.js +1 -0
- package/build/routes/chrome/http/content.post.body.json +8 -8
- package/build/routes/chrome/http/pdf.post.body.json +8 -8
- package/build/routes/chrome/http/scrape.post.body.json +8 -8
- package/build/routes/chrome/http/screenshot.post.body.json +9 -9
- package/build/routes/chromium/http/content.post.body.json +8 -8
- package/build/routes/chromium/http/pdf.post.body.json +8 -8
- package/build/routes/chromium/http/scrape.post.body.json +8 -8
- package/build/routes/chromium/http/screenshot.post.body.json +9 -9
- package/build/routes/management/http/active.get.d.ts +16 -0
- package/build/routes/management/http/active.get.js +17 -0
- package/build/routes/management/tests/management.spec.js +7 -0
- package/build/server.js +1 -1
- package/build/types.d.ts +6 -4
- package/build/types.js +1 -0
- package/build/utils.d.ts +1 -1
- package/docker/base/Dockerfile +1 -1
- package/extensions/ublock/1p-filters.html +4 -3
- package/extensions/ublock/3p-filters.html +3 -3
- package/extensions/ublock/_locales/ar/messages.json +16 -4
- package/extensions/ublock/_locales/az/messages.json +16 -4
- package/extensions/ublock/_locales/be/messages.json +19 -7
- package/extensions/ublock/_locales/bg/messages.json +16 -4
- package/extensions/ublock/_locales/bn/messages.json +33 -21
- package/extensions/ublock/_locales/br_FR/messages.json +33 -21
- package/extensions/ublock/_locales/bs/messages.json +16 -4
- package/extensions/ublock/_locales/ca/messages.json +16 -4
- package/extensions/ublock/_locales/cs/messages.json +16 -4
- package/extensions/ublock/_locales/cv/messages.json +16 -4
- package/extensions/ublock/_locales/cy/messages.json +16 -4
- package/extensions/ublock/_locales/da/messages.json +21 -9
- package/extensions/ublock/_locales/de/messages.json +17 -5
- package/extensions/ublock/_locales/el/messages.json +16 -4
- package/extensions/ublock/_locales/en/messages.json +16 -4
- package/extensions/ublock/_locales/en_GB/messages.json +16 -4
- package/extensions/ublock/_locales/eo/messages.json +17 -5
- package/extensions/ublock/_locales/es/messages.json +16 -4
- package/extensions/ublock/_locales/et/messages.json +16 -4
- package/extensions/ublock/_locales/eu/messages.json +16 -4
- package/extensions/ublock/_locales/fa/messages.json +24 -12
- package/extensions/ublock/_locales/fi/messages.json +16 -4
- package/extensions/ublock/_locales/fil/messages.json +16 -4
- package/extensions/ublock/_locales/fr/messages.json +16 -4
- package/extensions/ublock/_locales/fy/messages.json +16 -4
- package/extensions/ublock/_locales/gl/messages.json +16 -4
- package/extensions/ublock/_locales/gu/messages.json +16 -4
- package/extensions/ublock/_locales/he/messages.json +25 -13
- package/extensions/ublock/_locales/hi/messages.json +31 -19
- package/extensions/ublock/_locales/hr/messages.json +16 -4
- package/extensions/ublock/_locales/hu/messages.json +16 -4
- package/extensions/ublock/_locales/hy/messages.json +17 -5
- package/extensions/ublock/_locales/id/messages.json +16 -4
- package/extensions/ublock/_locales/it/messages.json +17 -5
- package/extensions/ublock/_locales/ja/messages.json +16 -4
- package/extensions/ublock/_locales/ka/messages.json +16 -4
- package/extensions/ublock/_locales/kk/messages.json +16 -4
- package/extensions/ublock/_locales/kn/messages.json +74 -62
- package/extensions/ublock/_locales/ko/messages.json +16 -4
- package/extensions/ublock/_locales/lt/messages.json +23 -11
- package/extensions/ublock/_locales/lv/messages.json +16 -4
- package/extensions/ublock/_locales/mk/messages.json +16 -4
- package/extensions/ublock/_locales/ml/messages.json +19 -7
- package/extensions/ublock/_locales/mr/messages.json +16 -4
- package/extensions/ublock/_locales/ms/messages.json +16 -4
- package/extensions/ublock/_locales/nb/messages.json +16 -4
- package/extensions/ublock/_locales/nl/messages.json +16 -4
- package/extensions/ublock/_locales/no/messages.json +16 -4
- package/extensions/ublock/_locales/oc/messages.json +16 -4
- package/extensions/ublock/_locales/pa/messages.json +16 -4
- package/extensions/ublock/_locales/pl/messages.json +17 -5
- package/extensions/ublock/_locales/pt_BR/messages.json +16 -4
- package/extensions/ublock/_locales/pt_PT/messages.json +16 -4
- package/extensions/ublock/_locales/ro/messages.json +17 -5
- package/extensions/ublock/_locales/ru/messages.json +16 -4
- package/extensions/ublock/_locales/si/messages.json +16 -4
- package/extensions/ublock/_locales/sk/messages.json +16 -4
- package/extensions/ublock/_locales/sl/messages.json +16 -4
- package/extensions/ublock/_locales/so/messages.json +16 -4
- package/extensions/ublock/_locales/sq/messages.json +16 -4
- package/extensions/ublock/_locales/sr/messages.json +16 -4
- package/extensions/ublock/_locales/sv/messages.json +20 -8
- package/extensions/ublock/_locales/sw/messages.json +16 -4
- package/extensions/ublock/_locales/ta/messages.json +16 -4
- package/extensions/ublock/_locales/te/messages.json +16 -4
- package/extensions/ublock/_locales/th/messages.json +42 -30
- package/extensions/ublock/_locales/tr/messages.json +19 -7
- package/extensions/ublock/_locales/uk/messages.json +16 -4
- package/extensions/ublock/_locales/ur/messages.json +16 -4
- package/extensions/ublock/_locales/vi/messages.json +16 -4
- package/extensions/ublock/_locales/zh_CN/messages.json +16 -4
- package/extensions/ublock/_locales/zh_TW/messages.json +42 -30
- package/extensions/ublock/assets/assets.json +95 -78
- package/extensions/ublock/assets/resources/scriptlets.js +70 -24
- package/extensions/ublock/assets/thirdparties/easylist/easylist.txt +6258 -3453
- package/extensions/ublock/assets/thirdparties/easylist/easyprivacy.txt +277 -40
- package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/serverlist +8 -32
- package/extensions/ublock/assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat +107 -12
- package/extensions/ublock/assets/thirdparties/urlhaus-filter/urlhaus-filter-online.txt +1160 -954
- package/extensions/ublock/assets/ublock/badlists.txt +1 -2
- package/extensions/ublock/assets/ublock/badware.min.txt +395 -270
- package/extensions/ublock/assets/ublock/filters.min.txt +1176 -1238
- package/extensions/ublock/assets/ublock/privacy.min.txt +32 -31
- package/extensions/ublock/assets/ublock/quick-fixes.min.txt +120 -110
- package/extensions/ublock/assets/ublock/unbreak.min.txt +75 -36
- package/extensions/ublock/css/1p-filters.css +2 -1
- package/extensions/ublock/css/3p-filters.css +1 -16
- package/extensions/ublock/css/advanced-settings.css +1 -0
- package/extensions/ublock/css/asset-viewer.css +1 -0
- package/extensions/ublock/css/code-viewer.css +1 -0
- package/extensions/ublock/css/codemirror.css +37 -10
- package/extensions/ublock/css/common.css +36 -2
- package/extensions/ublock/css/dashboard.css +9 -3
- package/extensions/ublock/css/devtools.css +1 -0
- package/extensions/ublock/css/document-blocked.css +3 -3
- package/extensions/ublock/css/dom-inspector.css +1 -0
- package/extensions/ublock/css/dyna-rules.css +1 -0
- package/extensions/ublock/css/epicker-ui.css +76 -66
- package/extensions/ublock/css/fa-icons.css +1 -0
- package/extensions/ublock/css/logger-ui.css +2 -0
- package/extensions/ublock/css/popup-fenix.css +1 -0
- package/extensions/ublock/css/whitelist.css +1 -0
- package/extensions/ublock/dashboard.html +20 -13
- package/extensions/ublock/devtools.html +2 -0
- package/extensions/ublock/dyna-rules.html +2 -2
- package/extensions/ublock/img/flags-of-the-world/np.png +0 -0
- package/extensions/ublock/img/fontawesome/fontawesome-defs.svg +1 -0
- package/extensions/ublock/js/1p-filters.js +72 -23
- package/extensions/ublock/js/3p-filters.js +71 -25
- package/extensions/ublock/js/asset-viewer.js +1 -0
- package/extensions/ublock/js/assets.js +83 -89
- package/extensions/ublock/js/background.js +20 -27
- package/extensions/ublock/js/base64-custom.js +1 -102
- package/extensions/ublock/js/benchmarks.js +36 -21
- package/extensions/ublock/js/biditrie.js +8 -23
- package/extensions/ublock/js/broadcast.js +2 -4
- package/extensions/ublock/js/cachestorage.js +594 -396
- package/extensions/ublock/js/codemirror/search.js +49 -37
- package/extensions/ublock/js/codemirror/ubo-static-filtering.js +233 -215
- package/extensions/ublock/js/contentscript-extra.js +31 -1
- package/extensions/ublock/js/cosmetic-filtering.js +35 -33
- package/extensions/ublock/js/dashboard.js +11 -7
- package/extensions/ublock/js/devtools.js +22 -0
- package/extensions/ublock/js/dom.js +2 -2
- package/extensions/ublock/js/dyna-rules.js +17 -16
- package/extensions/ublock/js/epicker-ui.js +41 -16
- package/extensions/ublock/js/fa-icons.js +1 -0
- package/extensions/ublock/js/hntrie.js +10 -25
- package/extensions/ublock/js/i18n.js +15 -15
- package/extensions/ublock/js/logger-ui.js +9 -6
- package/extensions/ublock/js/messaging.js +51 -26
- package/extensions/ublock/js/pagestore.js +21 -23
- package/extensions/ublock/js/popup-fenix.js +35 -22
- package/extensions/ublock/js/redirect-engine.js +15 -30
- package/extensions/ublock/js/reverselookup.js +1 -1
- package/extensions/ublock/js/s14e-serializer.js +1405 -0
- package/extensions/ublock/js/scriptlet-filtering-core.js +1 -1
- package/extensions/ublock/js/scriptlets/epicker.js +27 -18
- package/extensions/ublock/js/settings.js +32 -21
- package/extensions/ublock/js/start.js +121 -62
- package/extensions/ublock/js/static-ext-filtering-db.js +6 -6
- package/extensions/ublock/js/static-ext-filtering.js +17 -28
- package/extensions/ublock/js/static-filtering-parser.js +26 -4
- package/extensions/ublock/js/static-net-filtering.js +69 -168
- package/extensions/ublock/js/storage.js +178 -155
- package/extensions/ublock/js/traffic.js +11 -7
- package/extensions/ublock/js/vapi-background.js +49 -62
- package/extensions/ublock/js/vapi-client.js +13 -16
- package/extensions/ublock/js/webext.js +10 -2
- package/extensions/ublock/js/whitelist.js +27 -25
- package/extensions/ublock/lib/publicsuffixlist/publicsuffixlist.js +3 -7
- package/extensions/ublock/manifest.json +2 -1
- package/extensions/ublock/web_accessible_resources/epicker-ui.html +5 -8
- package/extensions/ublock/whitelist.html +3 -4
- package/package.json +12 -12
- package/src/config.ts +3 -4
- package/src/http.ts +1 -0
- package/src/routes/management/http/active.get.ts +30 -0
- package/src/routes/management/tests/management.spec.ts +13 -0
- package/src/server.ts +1 -1
- package/src/types.ts +2 -1
- package/static/docs/swagger.json +57 -11
- package/static/docs/swagger.min.json +56 -10
- package/static/function/client.js +4155 -3350
- package/extensions/ublock/_locales/ku/messages.json +0 -1294
|
@@ -19,11 +19,9 @@
|
|
|
19
19
|
Home: https://github.com/gorhill/uBlock
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
'use strict';
|
|
23
|
-
|
|
24
|
-
import { onBroadcast } from './broadcast.js';
|
|
25
22
|
import { dom, qs$, qsa$ } from './dom.js';
|
|
26
23
|
import { i18n, i18n$ } from './i18n.js';
|
|
24
|
+
import { onBroadcast } from './broadcast.js';
|
|
27
25
|
|
|
28
26
|
/******************************************************************************/
|
|
29
27
|
|
|
@@ -32,6 +30,10 @@ const obsoleteTemplateString = i18n$('3pExternalListObsolete');
|
|
|
32
30
|
const reValidExternalList = /^[a-z-]+:\/\/(?:\S+\/\S*|\/\S+)/m;
|
|
33
31
|
const recentlyUpdated = 1 * 60 * 60 * 1000; // 1 hour
|
|
34
32
|
|
|
33
|
+
// https://eslint.org/docs/latest/rules/no-prototype-builtins
|
|
34
|
+
const hasOwnProperty = (o, p) =>
|
|
35
|
+
Object.prototype.hasOwnProperty.call(o, p);
|
|
36
|
+
|
|
35
37
|
let listsetDetails = {};
|
|
36
38
|
|
|
37
39
|
/******************************************************************************/
|
|
@@ -74,7 +76,9 @@ const renderNodeStats = (used, total) => {
|
|
|
74
76
|
};
|
|
75
77
|
|
|
76
78
|
const i18nGroupName = name => {
|
|
77
|
-
|
|
79
|
+
const groupname = i18n$('3pGroup' + name.charAt(0).toUpperCase() + name.slice(1));
|
|
80
|
+
if ( groupname !== '' ) { return groupname; }
|
|
81
|
+
return `${name.charAt(0).toLocaleUpperCase}${name.slice(1)}`;
|
|
78
82
|
};
|
|
79
83
|
|
|
80
84
|
/******************************************************************************/
|
|
@@ -90,8 +94,9 @@ const renderFilterLists = ( ) => {
|
|
|
90
94
|
|
|
91
95
|
const initializeListEntry = (listDetails, listEntry) => {
|
|
92
96
|
const listkey = listEntry.dataset.key;
|
|
97
|
+
const groupkey = listDetails.group2 || listDetails.group;
|
|
93
98
|
const listEntryPrevious =
|
|
94
|
-
qs$(`[data-key="${
|
|
99
|
+
qs$(`[data-key="${groupkey}"] [data-key="${listkey}"]`);
|
|
95
100
|
if ( listEntryPrevious !== null ) {
|
|
96
101
|
if ( dom.cl.has(listEntryPrevious, 'checked') ) {
|
|
97
102
|
dom.cl.add(listEntry, 'checked');
|
|
@@ -179,6 +184,9 @@ const renderFilterLists = ( ) => {
|
|
|
179
184
|
if ( depth !== 0 ) {
|
|
180
185
|
const reEmojis = /\p{Emoji}+/gu;
|
|
181
186
|
treeEntries.sort((a ,b) => {
|
|
187
|
+
const ap = a[1].preferred === true;
|
|
188
|
+
const bp = b[1].preferred === true;
|
|
189
|
+
if ( ap !== bp ) { return ap ? -1 : 1; }
|
|
182
190
|
const as = (a[1].title || a[0]).replace(reEmojis, '');
|
|
183
191
|
const bs = (b[1].title || b[0]).replace(reEmojis, '');
|
|
184
192
|
return as.localeCompare(bs);
|
|
@@ -223,8 +231,11 @@ const renderFilterLists = ( ) => {
|
|
|
223
231
|
'privacy',
|
|
224
232
|
'malware',
|
|
225
233
|
'multipurpose',
|
|
234
|
+
'cookies',
|
|
235
|
+
'social',
|
|
226
236
|
'annoyances',
|
|
227
237
|
'regions',
|
|
238
|
+
'unknown',
|
|
228
239
|
'custom'
|
|
229
240
|
];
|
|
230
241
|
for ( const key of groupKeys ) {
|
|
@@ -234,17 +245,20 @@ const renderFilterLists = ( ) => {
|
|
|
234
245
|
};
|
|
235
246
|
}
|
|
236
247
|
for ( const [ listkey, listDetails ] of Object.entries(response.available) ) {
|
|
237
|
-
let
|
|
238
|
-
if (
|
|
239
|
-
|
|
248
|
+
let groupkey = listDetails.group2 || listDetails.group;
|
|
249
|
+
if ( hasOwnProperty(listTree, groupkey) === false ) {
|
|
250
|
+
groupkey = 'unknown';
|
|
240
251
|
}
|
|
241
|
-
const groupDetails = listTree[
|
|
252
|
+
const groupDetails = listTree[groupkey];
|
|
242
253
|
if ( listDetails.parent !== undefined ) {
|
|
243
254
|
let lists = groupDetails.lists;
|
|
244
255
|
for ( const parent of listDetails.parent.split('|') ) {
|
|
245
256
|
if ( lists[parent] === undefined ) {
|
|
246
257
|
lists[parent] = { title: parent, lists: {} };
|
|
247
258
|
}
|
|
259
|
+
if ( listDetails.preferred === true ) {
|
|
260
|
+
lists[parent].preferred = true;
|
|
261
|
+
}
|
|
248
262
|
lists = lists[parent].lists;
|
|
249
263
|
}
|
|
250
264
|
lists[listkey] = listDetails;
|
|
@@ -253,6 +267,15 @@ const renderFilterLists = ( ) => {
|
|
|
253
267
|
groupDetails.lists[listkey] = listDetails;
|
|
254
268
|
}
|
|
255
269
|
}
|
|
270
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/3154#issuecomment-1975413427
|
|
271
|
+
// Remove empty sections
|
|
272
|
+
for ( const groupkey of groupKeys ) {
|
|
273
|
+
const groupDetails = listTree[groupkey];
|
|
274
|
+
if ( groupDetails === undefined ) { continue; }
|
|
275
|
+
if ( Object.keys(groupDetails.lists).length !== 0 ) { continue; }
|
|
276
|
+
delete listTree[groupkey];
|
|
277
|
+
}
|
|
278
|
+
|
|
256
279
|
const listEntries = createListEntries('root', listTree);
|
|
257
280
|
qs$('#lists .listEntries').replaceWith(listEntries);
|
|
258
281
|
|
|
@@ -530,6 +553,35 @@ dom.on('#lists', 'click', 'span.cache', onPurgeClicked);
|
|
|
530
553
|
/******************************************************************************/
|
|
531
554
|
|
|
532
555
|
const selectFilterLists = async ( ) => {
|
|
556
|
+
// External filter lists to import
|
|
557
|
+
// Find stock list matching entries in lists to import
|
|
558
|
+
const toImport = (( ) => {
|
|
559
|
+
const textarea = qs$('#lists .listEntry[data-role="import"].expanded textarea');
|
|
560
|
+
if ( textarea === null ) { return ''; }
|
|
561
|
+
const lists = listsetDetails.available;
|
|
562
|
+
const lines = textarea.value.split(/\s+\n|\s+/);
|
|
563
|
+
const after = [];
|
|
564
|
+
for ( const line of lines ) {
|
|
565
|
+
if ( /^https?:\/\//.test(line) === false ) { continue; }
|
|
566
|
+
for ( const [ listkey, list ] of Object.entries(lists) ) {
|
|
567
|
+
if ( list.content !== 'filters' ) { continue; }
|
|
568
|
+
if ( list.contentURL === undefined ) { continue; }
|
|
569
|
+
if ( list.contentURL.includes(line) === false ) {
|
|
570
|
+
after.push(line);
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
const groupkey = list.group2 || list.group;
|
|
574
|
+
const listEntry = qs$(`[data-key="${groupkey}"] [data-key="${listkey}"]`);
|
|
575
|
+
if ( listEntry === null ) { break; }
|
|
576
|
+
toggleFilterList(listEntry, true);
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
dom.cl.remove(textarea.closest('.expandable'), 'expanded');
|
|
581
|
+
textarea.value = '';
|
|
582
|
+
return after.join('\n');
|
|
583
|
+
})();
|
|
584
|
+
|
|
533
585
|
// Cosmetic filtering switch
|
|
534
586
|
let checked = qs$('#parseCosmeticFilters').checked;
|
|
535
587
|
vAPI.messaging.send('dashboard', {
|
|
@@ -552,7 +604,7 @@ const selectFilterLists = async ( ) => {
|
|
|
552
604
|
const toRemove = [];
|
|
553
605
|
for ( const liEntry of qsa$('#lists .listEntry[data-role="leaf"]') ) {
|
|
554
606
|
const listkey = liEntry.dataset.key;
|
|
555
|
-
if ( listsetDetails.available
|
|
607
|
+
if ( hasOwnProperty(listsetDetails.available, listkey) === false ) {
|
|
556
608
|
continue;
|
|
557
609
|
}
|
|
558
610
|
const listDetails = listsetDetails.available[listkey];
|
|
@@ -569,14 +621,6 @@ const selectFilterLists = async ( ) => {
|
|
|
569
621
|
}
|
|
570
622
|
}
|
|
571
623
|
|
|
572
|
-
// External filter lists to import
|
|
573
|
-
const textarea = qs$('#lists .listEntry[data-role="import"].expanded textarea');
|
|
574
|
-
const toImport = textarea !== null && textarea.value.trim() || '';
|
|
575
|
-
if ( textarea !== null ) {
|
|
576
|
-
dom.cl.remove(textarea.closest('.expandable'), 'expanded');
|
|
577
|
-
textarea.value = '';
|
|
578
|
-
}
|
|
579
|
-
|
|
580
624
|
hashFromListsetDetails();
|
|
581
625
|
|
|
582
626
|
await vAPI.messaging.send('dashboard', {
|
|
@@ -630,7 +674,7 @@ dom.on('#suspendUntilListsAreLoaded', 'change', userSettingCheckboxChanged);
|
|
|
630
674
|
/******************************************************************************/
|
|
631
675
|
|
|
632
676
|
const searchFilterLists = ( ) => {
|
|
633
|
-
const pattern = dom.prop('.
|
|
677
|
+
const pattern = dom.prop('.searchfield input', 'value') || '';
|
|
634
678
|
dom.cl.toggle('#lists', 'searchMode', pattern !== '');
|
|
635
679
|
if ( pattern === '' ) { return; }
|
|
636
680
|
const reflectSearchMatches = listEntry => {
|
|
@@ -657,10 +701,11 @@ const searchFilterLists = ( ) => {
|
|
|
657
701
|
if ( listDetails === undefined ) { continue; }
|
|
658
702
|
let haystack = perListHaystack.get(listDetails);
|
|
659
703
|
if ( haystack === undefined ) {
|
|
704
|
+
const groupkey = listDetails.group2 || listDetails.group || '';
|
|
660
705
|
haystack = [
|
|
661
706
|
listDetails.title,
|
|
662
|
-
|
|
663
|
-
i18nGroupName(
|
|
707
|
+
groupkey,
|
|
708
|
+
i18nGroupName(groupkey),
|
|
664
709
|
listDetails.tags || '',
|
|
665
710
|
toI18n(listDetails.tags || ''),
|
|
666
711
|
].join(' ').trim();
|
|
@@ -673,14 +718,13 @@ const searchFilterLists = ( ) => {
|
|
|
673
718
|
|
|
674
719
|
const perListHaystack = new WeakMap();
|
|
675
720
|
|
|
676
|
-
dom.on('.
|
|
721
|
+
dom.on('.searchfield input', 'input', searchFilterLists);
|
|
677
722
|
|
|
678
723
|
/******************************************************************************/
|
|
679
724
|
|
|
680
725
|
const expandedListSet = new Set([
|
|
681
|
-
'
|
|
682
|
-
'
|
|
683
|
-
'EasyList – Annoyances',
|
|
726
|
+
'cookies',
|
|
727
|
+
'social',
|
|
684
728
|
]);
|
|
685
729
|
|
|
686
730
|
const listIsExpanded = which => {
|
|
@@ -844,6 +888,8 @@ self.cloud.onPull = function fromCloudData(data, append) {
|
|
|
844
888
|
|
|
845
889
|
/******************************************************************************/
|
|
846
890
|
|
|
891
|
+
self.wikilink = 'https://github.com/gorhill/uBlock/wiki/Dashboard:-Filter-lists';
|
|
892
|
+
|
|
847
893
|
self.hasUnsavedData = function() {
|
|
848
894
|
return hashFromCurrentFromSettings() !== filteringSettingsHash;
|
|
849
895
|
};
|
|
@@ -528,12 +528,12 @@ function getAssetSourceRegistry() {
|
|
|
528
528
|
assetSourceRegistryPromise = cacheStorage.get(
|
|
529
529
|
'assetSourceRegistry'
|
|
530
530
|
).then(bin => {
|
|
531
|
-
if (
|
|
532
|
-
bin instanceof Object
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
531
|
+
if ( bin instanceof Object ) {
|
|
532
|
+
if ( bin.assetSourceRegistry instanceof Object ) {
|
|
533
|
+
assetSourceRegistry = bin.assetSourceRegistry;
|
|
534
|
+
ubolog('Loaded assetSourceRegistry');
|
|
535
|
+
return assetSourceRegistry;
|
|
536
|
+
}
|
|
537
537
|
}
|
|
538
538
|
return assets.fetchText(
|
|
539
539
|
µb.assetsBootstrapLocation || µb.assetsJsonPath
|
|
@@ -543,6 +543,7 @@ function getAssetSourceRegistry() {
|
|
|
543
543
|
: assets.fetchText(µb.assetsJsonPath);
|
|
544
544
|
}).then(details => {
|
|
545
545
|
updateAssetSourceRegistry(details.content, true);
|
|
546
|
+
ubolog('Loaded assetSourceRegistry');
|
|
546
547
|
return assetSourceRegistry;
|
|
547
548
|
});
|
|
548
549
|
});
|
|
@@ -673,49 +674,36 @@ let assetCacheRegistryPromise;
|
|
|
673
674
|
let assetCacheRegistry = {};
|
|
674
675
|
|
|
675
676
|
function getAssetCacheRegistry() {
|
|
676
|
-
if ( assetCacheRegistryPromise
|
|
677
|
-
assetCacheRegistryPromise
|
|
678
|
-
'assetCacheRegistry'
|
|
679
|
-
).then(bin => {
|
|
680
|
-
if (
|
|
681
|
-
bin instanceof Object &&
|
|
682
|
-
bin.assetCacheRegistry instanceof Object
|
|
683
|
-
) {
|
|
684
|
-
if ( Object.keys(assetCacheRegistry).length === 0 ) {
|
|
685
|
-
assetCacheRegistry = bin.assetCacheRegistry;
|
|
686
|
-
} else {
|
|
687
|
-
console.error(
|
|
688
|
-
'getAssetCacheRegistry(): assetCacheRegistry reassigned!'
|
|
689
|
-
);
|
|
690
|
-
if (
|
|
691
|
-
Object.keys(bin.assetCacheRegistry).sort().join() !==
|
|
692
|
-
Object.keys(assetCacheRegistry).sort().join()
|
|
693
|
-
) {
|
|
694
|
-
console.error(
|
|
695
|
-
'getAssetCacheRegistry(): assetCacheRegistry changes overwritten!'
|
|
696
|
-
);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
return assetCacheRegistry;
|
|
701
|
-
});
|
|
677
|
+
if ( assetCacheRegistryPromise !== undefined ) {
|
|
678
|
+
return assetCacheRegistryPromise;
|
|
702
679
|
}
|
|
703
|
-
|
|
680
|
+
assetCacheRegistryPromise = cacheStorage.get(
|
|
681
|
+
'assetCacheRegistry'
|
|
682
|
+
).then(bin => {
|
|
683
|
+
if ( bin instanceof Object === false ) { return; }
|
|
684
|
+
if ( bin.assetCacheRegistry instanceof Object === false ) { return; }
|
|
685
|
+
if ( Object.keys(assetCacheRegistry).length !== 0 ) {
|
|
686
|
+
return console.error('getAssetCacheRegistry(): assetCacheRegistry reassigned!');
|
|
687
|
+
}
|
|
688
|
+
ubolog('Loaded assetCacheRegistry');
|
|
689
|
+
assetCacheRegistry = bin.assetCacheRegistry;
|
|
690
|
+
}).then(( ) =>
|
|
691
|
+
assetCacheRegistry
|
|
692
|
+
);
|
|
704
693
|
return assetCacheRegistryPromise;
|
|
705
694
|
}
|
|
706
695
|
|
|
707
696
|
const saveAssetCacheRegistry = (( ) => {
|
|
708
|
-
const save =
|
|
697
|
+
const save = ( ) => {
|
|
709
698
|
timer.off();
|
|
710
|
-
cacheStorage.set({ assetCacheRegistry });
|
|
699
|
+
return cacheStorage.set({ assetCacheRegistry });
|
|
711
700
|
};
|
|
712
701
|
const timer = vAPI.defer.create(save);
|
|
713
|
-
return
|
|
714
|
-
if (
|
|
715
|
-
|
|
716
|
-
} else {
|
|
717
|
-
save();
|
|
702
|
+
return (throttle = 0) => {
|
|
703
|
+
if ( throttle === 0 ) {
|
|
704
|
+
return save();
|
|
718
705
|
}
|
|
706
|
+
timer.offon({ sec: throttle });
|
|
719
707
|
};
|
|
720
708
|
})();
|
|
721
709
|
|
|
@@ -726,7 +714,9 @@ async function assetCacheRead(assetKey, updateReadTime = false) {
|
|
|
726
714
|
const reportBack = function(content) {
|
|
727
715
|
if ( content instanceof Blob ) { content = ''; }
|
|
728
716
|
const details = { assetKey, content };
|
|
729
|
-
if ( content === ''
|
|
717
|
+
if ( content === '' || content === undefined ) {
|
|
718
|
+
details.error = 'ENOTFOUND';
|
|
719
|
+
}
|
|
730
720
|
return details;
|
|
731
721
|
};
|
|
732
722
|
|
|
@@ -742,55 +732,39 @@ async function assetCacheRead(assetKey, updateReadTime = false) {
|
|
|
742
732
|
) + ' ms';
|
|
743
733
|
}
|
|
744
734
|
|
|
745
|
-
if (
|
|
746
|
-
|
|
747
|
-
bin.hasOwnProperty(internalKey) === false
|
|
748
|
-
) {
|
|
749
|
-
return reportBack('');
|
|
750
|
-
}
|
|
735
|
+
if ( bin instanceof Object === false ) { return reportBack(''); }
|
|
736
|
+
if ( bin.hasOwnProperty(internalKey) === false ) { return reportBack(''); }
|
|
751
737
|
|
|
752
738
|
const entry = assetCacheRegistry[assetKey];
|
|
753
|
-
if ( entry === undefined ) {
|
|
754
|
-
return reportBack('');
|
|
755
|
-
}
|
|
739
|
+
if ( entry === undefined ) { return reportBack(''); }
|
|
756
740
|
|
|
757
741
|
entry.readTime = Date.now();
|
|
758
742
|
if ( updateReadTime ) {
|
|
759
|
-
saveAssetCacheRegistry(
|
|
743
|
+
saveAssetCacheRegistry(23);
|
|
760
744
|
}
|
|
761
745
|
|
|
762
746
|
return reportBack(bin[internalKey]);
|
|
763
747
|
}
|
|
764
748
|
|
|
765
|
-
async function assetCacheWrite(assetKey,
|
|
766
|
-
|
|
767
|
-
let options = {};
|
|
768
|
-
if ( typeof details === 'string' ) {
|
|
769
|
-
content = details;
|
|
770
|
-
} else if ( details instanceof Object ) {
|
|
771
|
-
content = details.content || '';
|
|
772
|
-
options = details;
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
if ( content === '' ) {
|
|
749
|
+
async function assetCacheWrite(assetKey, content, options = {}) {
|
|
750
|
+
if ( content === '' || content === undefined ) {
|
|
776
751
|
return assetCacheRemove(assetKey);
|
|
777
752
|
}
|
|
778
753
|
|
|
779
754
|
const cacheDict = await getAssetCacheRegistry();
|
|
780
755
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
entry = cacheDict[assetKey] = {};
|
|
784
|
-
}
|
|
756
|
+
const { resourceTime, url } = options;
|
|
757
|
+
const entry = cacheDict[assetKey] || {};
|
|
785
758
|
entry.writeTime = entry.readTime = Date.now();
|
|
786
|
-
entry.resourceTime =
|
|
787
|
-
if ( typeof
|
|
788
|
-
entry.remoteURL =
|
|
759
|
+
entry.resourceTime = resourceTime || 0;
|
|
760
|
+
if ( typeof url === 'string' ) {
|
|
761
|
+
entry.remoteURL = url;
|
|
789
762
|
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
763
|
+
cacheDict[assetKey] = entry;
|
|
764
|
+
|
|
765
|
+
await cacheStorage.set({ [`cache/${assetKey}`]: content });
|
|
766
|
+
|
|
767
|
+
saveAssetCacheRegistry(3);
|
|
794
768
|
|
|
795
769
|
const result = { assetKey, content };
|
|
796
770
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/248
|
|
@@ -800,21 +774,31 @@ async function assetCacheWrite(assetKey, details) {
|
|
|
800
774
|
return result;
|
|
801
775
|
}
|
|
802
776
|
|
|
803
|
-
async function assetCacheRemove(pattern) {
|
|
777
|
+
async function assetCacheRemove(pattern, options = {}) {
|
|
804
778
|
const cacheDict = await getAssetCacheRegistry();
|
|
805
779
|
const removedEntries = [];
|
|
806
780
|
const removedContent = [];
|
|
807
781
|
for ( const assetKey in cacheDict ) {
|
|
808
|
-
if ( pattern instanceof RegExp
|
|
809
|
-
continue;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
continue;
|
|
782
|
+
if ( pattern instanceof RegExp ) {
|
|
783
|
+
if ( pattern.test(assetKey) === false ) { continue; }
|
|
784
|
+
} else if ( typeof pattern === 'string' ) {
|
|
785
|
+
if ( assetKey !== pattern ) { continue; }
|
|
813
786
|
}
|
|
814
787
|
removedEntries.push(assetKey);
|
|
815
|
-
removedContent.push(
|
|
788
|
+
removedContent.push(`cache/${assetKey}`);
|
|
816
789
|
delete cacheDict[assetKey];
|
|
817
790
|
}
|
|
791
|
+
if ( options.janitor && pattern instanceof RegExp ) {
|
|
792
|
+
const re = new RegExp(
|
|
793
|
+
pattern.source.replace(/^\^/, '^cache\\/'),
|
|
794
|
+
pattern.flags
|
|
795
|
+
);
|
|
796
|
+
const keys = await cacheStorage.keys(re);
|
|
797
|
+
for ( const key of keys ) {
|
|
798
|
+
removedContent.push(key);
|
|
799
|
+
ubolog(`Removing stray ${key}`);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
818
802
|
if ( removedContent.length !== 0 ) {
|
|
819
803
|
await Promise.all([
|
|
820
804
|
cacheStorage.remove(removedContent),
|
|
@@ -854,7 +838,7 @@ async function assetCacheSetDetails(assetKey, details) {
|
|
|
854
838
|
}
|
|
855
839
|
}
|
|
856
840
|
if ( modified ) {
|
|
857
|
-
saveAssetCacheRegistry();
|
|
841
|
+
saveAssetCacheRegistry(3);
|
|
858
842
|
}
|
|
859
843
|
}
|
|
860
844
|
|
|
@@ -980,8 +964,7 @@ assets.get = async function(assetKey, options = {}) {
|
|
|
980
964
|
}
|
|
981
965
|
if ( details.content === '' ) { continue; }
|
|
982
966
|
if ( reIsExternalPath.test(contentURL) && options.dontCache !== true ) {
|
|
983
|
-
assetCacheWrite(assetKey, {
|
|
984
|
-
content: details.content,
|
|
967
|
+
assetCacheWrite(assetKey, details.content, {
|
|
985
968
|
url: contentURL,
|
|
986
969
|
silent: options.silent === true,
|
|
987
970
|
});
|
|
@@ -1057,8 +1040,7 @@ async function getRemote(assetKey, options = {}) {
|
|
|
1057
1040
|
}
|
|
1058
1041
|
|
|
1059
1042
|
// Success
|
|
1060
|
-
assetCacheWrite(assetKey, {
|
|
1061
|
-
content: result.content,
|
|
1043
|
+
assetCacheWrite(assetKey, result.content, {
|
|
1062
1044
|
url: contentURL,
|
|
1063
1045
|
resourceTime: result.resourceTime || 0,
|
|
1064
1046
|
});
|
|
@@ -1101,6 +1083,17 @@ assets.put = async function(assetKey, content) {
|
|
|
1101
1083
|
|
|
1102
1084
|
/******************************************************************************/
|
|
1103
1085
|
|
|
1086
|
+
assets.toCache = async function(assetKey, content) {
|
|
1087
|
+
return assetCacheWrite(assetKey, content);
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
assets.fromCache = async function(assetKey) {
|
|
1091
|
+
const details = await assetCacheRead(assetKey);
|
|
1092
|
+
return details && details.content;
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
/******************************************************************************/
|
|
1096
|
+
|
|
1104
1097
|
assets.metadata = async function() {
|
|
1105
1098
|
await Promise.all([
|
|
1106
1099
|
getAssetSourceRegistry(),
|
|
@@ -1147,8 +1140,8 @@ assets.metadata = async function() {
|
|
|
1147
1140
|
|
|
1148
1141
|
assets.purge = assetCacheMarkAsDirty;
|
|
1149
1142
|
|
|
1150
|
-
assets.remove = function(
|
|
1151
|
-
return assetCacheRemove(
|
|
1143
|
+
assets.remove = function(...args) {
|
|
1144
|
+
return assetCacheRemove(...args);
|
|
1152
1145
|
};
|
|
1153
1146
|
|
|
1154
1147
|
assets.rmrf = function() {
|
|
@@ -1300,8 +1293,7 @@ async function diffUpdater() {
|
|
|
1300
1293
|
'Diff-Path',
|
|
1301
1294
|
'Diff-Expires',
|
|
1302
1295
|
]);
|
|
1303
|
-
assetCacheWrite(data.assetKey, {
|
|
1304
|
-
content: data.text,
|
|
1296
|
+
assetCacheWrite(data.assetKey, data.text, {
|
|
1305
1297
|
resourceTime: metadata.lastModified || 0,
|
|
1306
1298
|
});
|
|
1307
1299
|
metadata.diffUpdated = true;
|
|
@@ -1333,6 +1325,8 @@ async function diffUpdater() {
|
|
|
1333
1325
|
terminate();
|
|
1334
1326
|
};
|
|
1335
1327
|
const worker = new Worker('js/diff-updater.js');
|
|
1328
|
+
}).catch(reason => {
|
|
1329
|
+
ubolog(`Diff updater: ${reason}`);
|
|
1336
1330
|
});
|
|
1337
1331
|
}
|
|
1338
1332
|
|
|
@@ -19,22 +19,18 @@
|
|
|
19
19
|
Home: https://github.com/gorhill/uBlock
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
/* globals browser */
|
|
23
|
-
|
|
24
|
-
'use strict';
|
|
25
|
-
|
|
26
22
|
/******************************************************************************/
|
|
27
23
|
|
|
28
|
-
import logger from './logger.js';
|
|
29
|
-
import { FilteringContext } from './filtering-context.js';
|
|
30
|
-
import { ubologSet } from './console.js';
|
|
31
|
-
|
|
32
24
|
import {
|
|
33
25
|
domainFromHostname,
|
|
34
26
|
hostnameFromURI,
|
|
35
27
|
originFromURI,
|
|
36
28
|
} from './uri-utils.js';
|
|
37
29
|
|
|
30
|
+
import { FilteringContext } from './filtering-context.js';
|
|
31
|
+
import logger from './logger.js';
|
|
32
|
+
import { ubologSet } from './console.js';
|
|
33
|
+
|
|
38
34
|
/******************************************************************************/
|
|
39
35
|
|
|
40
36
|
// Not all platforms may have properly declared vAPI.webextFlavor.
|
|
@@ -49,13 +45,14 @@ const hiddenSettingsDefault = {
|
|
|
49
45
|
allowGenericProceduralFilters: false,
|
|
50
46
|
assetFetchTimeout: 30,
|
|
51
47
|
autoCommentFilterTemplate: '{{date}} {{origin}}',
|
|
52
|
-
autoUpdateAssetFetchPeriod:
|
|
53
|
-
autoUpdateDelayAfterLaunch:
|
|
48
|
+
autoUpdateAssetFetchPeriod: 5,
|
|
49
|
+
autoUpdateDelayAfterLaunch: 37,
|
|
54
50
|
autoUpdatePeriod: 1,
|
|
55
51
|
benchmarkDatasetURL: 'unset',
|
|
56
52
|
blockingProfiles: '11111/#F00 11010/#C0F 11001/#00F 00001',
|
|
57
|
-
cacheStorageAPI: 'unset',
|
|
58
53
|
cacheStorageCompression: true,
|
|
54
|
+
cacheStorageCompressionThreshold: 65536,
|
|
55
|
+
cacheStorageMultithread: 2,
|
|
59
56
|
cacheControlForFirefox1376932: 'no-cache, no-store, must-revalidate',
|
|
60
57
|
cloudStorageCompression: true,
|
|
61
58
|
cnameIgnoreList: 'unset',
|
|
@@ -78,10 +75,12 @@ const hiddenSettingsDefault = {
|
|
|
78
75
|
modifyWebextFlavor: 'unset',
|
|
79
76
|
popupFontSize: 'unset',
|
|
80
77
|
popupPanelDisabledSections: 0,
|
|
81
|
-
popupPanelLockedSections: 0,
|
|
82
78
|
popupPanelHeightMode: 0,
|
|
79
|
+
popupPanelLockedSections: 0,
|
|
80
|
+
popupPanelOrientation: 'unset',
|
|
83
81
|
requestJournalProcessPeriod: 1000,
|
|
84
|
-
|
|
82
|
+
requestStatsDisabled: false,
|
|
83
|
+
selfieDelayInSeconds: 53,
|
|
85
84
|
strictBlockingBypassDuration: 120,
|
|
86
85
|
toolbarWarningTimeout: 60,
|
|
87
86
|
trustedListPrefixes: 'ublock-',
|
|
@@ -93,7 +92,7 @@ const hiddenSettingsDefault = {
|
|
|
93
92
|
|
|
94
93
|
if ( vAPI.webextFlavor.soup.has('devbuild') ) {
|
|
95
94
|
hiddenSettingsDefault.consoleLogLevel = 'info';
|
|
96
|
-
hiddenSettingsDefault.
|
|
95
|
+
hiddenSettingsDefault.cacheStorageAPI = 'unset';
|
|
97
96
|
ubologSet(true);
|
|
98
97
|
}
|
|
99
98
|
|
|
@@ -112,7 +111,7 @@ const userSettingsDefault = {
|
|
|
112
111
|
externalLists: '',
|
|
113
112
|
firewallPaneMinimized: true,
|
|
114
113
|
hyperlinkAuditingDisabled: true,
|
|
115
|
-
ignoreGenericCosmeticFilters:
|
|
114
|
+
ignoreGenericCosmeticFilters: false,
|
|
116
115
|
importedLists: [],
|
|
117
116
|
largeMediaSize: 50,
|
|
118
117
|
parseAllABPHideFilters: true,
|
|
@@ -122,6 +121,7 @@ const userSettingsDefault = {
|
|
|
122
121
|
showIconBadge: true,
|
|
123
122
|
suspendUntilListsAreLoaded: vAPI.Net.canSuspend(),
|
|
124
123
|
tooltipsDisabled: false,
|
|
124
|
+
userFiltersTrusted: false,
|
|
125
125
|
webrtcIPAddressHidden: false,
|
|
126
126
|
};
|
|
127
127
|
|
|
@@ -144,7 +144,7 @@ if ( vAPI.webextFlavor.soup.has('firefox') ) {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
const µBlock = { // jshint ignore:line
|
|
147
|
-
|
|
147
|
+
alarmQueue: [],
|
|
148
148
|
|
|
149
149
|
userSettingsDefault,
|
|
150
150
|
userSettings: Object.assign({}, userSettingsDefault),
|
|
@@ -168,26 +168,19 @@ const µBlock = { // jshint ignore:line
|
|
|
168
168
|
netWhitelist: new Map(),
|
|
169
169
|
netWhitelistModifyTime: 0,
|
|
170
170
|
netWhitelistDefault: [
|
|
171
|
-
'about-scheme',
|
|
172
171
|
'chrome-extension-scheme',
|
|
173
|
-
'chrome-scheme',
|
|
174
|
-
'edge-scheme',
|
|
175
172
|
'moz-extension-scheme',
|
|
176
|
-
'opera-scheme',
|
|
177
|
-
'vivaldi-scheme',
|
|
178
|
-
'wyciwyg-scheme', // Firefox's "What-You-Cache-Is-What-You-Get"
|
|
179
173
|
],
|
|
180
174
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
175
|
+
requestStats: {
|
|
176
|
+
blockedCount: 0,
|
|
177
|
+
allowedCount: 0,
|
|
184
178
|
},
|
|
185
|
-
localSettingsLastModified: 0,
|
|
186
179
|
|
|
187
180
|
// Read-only
|
|
188
181
|
systemSettings: {
|
|
189
182
|
compiledMagic: 57, // Increase when compiled format changes
|
|
190
|
-
selfieMagic:
|
|
183
|
+
selfieMagic: 58, // Increase when selfie format changes
|
|
191
184
|
},
|
|
192
185
|
|
|
193
186
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/759#issuecomment-546654501
|