@browserless.io/browserless 2.0.0-beta-5 → 2.0.0-beta-7
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/LICENSE +2 -0
- package/README.md +11 -11
- package/bin/browserless.js +169 -11
- package/bin/scaffold/README.md +415 -0
- package/bin/scaffold/package.json +21 -0
- package/bin/scaffold/src/hello-world.http.ts +27 -0
- package/bin/scaffold/tsconfig.json +4 -0
- package/build/browserless.js +18 -15
- package/build/browsers/index.d.ts +2 -18
- package/build/browsers/index.js +43 -14
- package/build/file-system.d.ts +5 -0
- package/build/file-system.js +20 -5
- package/build/file-system.spec.d.ts +1 -0
- package/build/file-system.spec.js +44 -0
- package/build/http.d.ts +3 -3
- package/build/http.js +3 -3
- package/build/router.js +2 -4
- package/build/routes/chromium/http/content-post.body.json +8 -8
- package/build/routes/chromium/http/content-post.d.ts +15 -3
- package/build/routes/chromium/http/content-post.js +14 -15
- package/build/routes/chromium/http/download-post.d.ts +16 -3
- package/build/routes/chromium/http/download-post.js +17 -22
- package/build/routes/chromium/http/function-post.d.ts +16 -3
- package/build/routes/chromium/http/function-post.js +17 -22
- package/build/routes/chromium/http/pdf-post.body.json +8 -8
- package/build/routes/chromium/http/pdf-post.d.ts +15 -3
- package/build/routes/chromium/http/pdf-post.js +19 -15
- package/build/routes/chromium/http/performance.d.ts +15 -3
- package/build/routes/chromium/http/performance.js +15 -23
- package/build/routes/chromium/http/scrape-post.body.json +8 -8
- package/build/routes/chromium/http/scrape-post.d.ts +15 -3
- package/build/routes/chromium/http/scrape-post.js +15 -16
- package/build/routes/chromium/http/screenshot-post.body.json +8 -8
- package/build/routes/chromium/http/screenshot-post.d.ts +15 -3
- package/build/routes/chromium/http/screenshot-post.js +18 -15
- package/build/routes/chromium/tests/websocket.spec.js +20 -1
- package/build/routes/chromium/utils/function/handler.js +2 -2
- package/build/routes/chromium/ws/browser.d.ts +13 -3
- package/build/routes/chromium/ws/browser.js +10 -11
- package/build/routes/chromium/ws/cdp-chromium.d.ts +13 -3
- package/build/routes/chromium/ws/cdp-chromium.js +10 -11
- package/build/routes/chromium/ws/page.d.ts +13 -3
- package/build/routes/chromium/ws/page.js +10 -11
- package/build/routes/chromium/ws/playwright-chromium.d.ts +13 -3
- package/build/routes/chromium/ws/playwright-chromium.js +11 -12
- package/build/routes/firefox/ws/playwright-firefox.d.ts +13 -3
- package/build/routes/firefox/ws/playwright-firefox.js +11 -12
- package/build/routes/management/http/config-get.d.ts +15 -3
- package/build/routes/management/http/config-get.js +15 -20
- package/build/routes/management/http/metrics-get.d.ts +15 -3
- package/build/routes/management/http/metrics-get.js +16 -21
- package/build/routes/management/http/metrics-total-get.d.ts +15 -3
- package/build/routes/management/http/metrics-total-get.js +16 -21
- package/build/routes/management/http/sessions-get.d.ts +15 -3
- package/build/routes/management/http/sessions-get.js +16 -20
- package/build/routes/management/http/static-get.d.ts +15 -3
- package/build/routes/management/http/static-get.js +15 -20
- package/build/routes/webkit/ws/playwright-webkit.d.ts +13 -3
- package/build/routes/webkit/ws/playwright-webkit.js +11 -12
- package/build/server.js +0 -1
- package/build/types.d.ts +48 -38
- package/build/types.js +135 -0
- package/extensions/ublock/1p-filters.html +0 -1
- package/extensions/ublock/3p-filters.html +0 -2
- package/extensions/ublock/_locales/bg/messages.json +6 -6
- package/extensions/ublock/_locales/br_FR/messages.json +14 -14
- package/extensions/ublock/_locales/bs/messages.json +8 -8
- package/extensions/ublock/_locales/ca/messages.json +1 -1
- package/extensions/ublock/_locales/da/messages.json +5 -5
- package/extensions/ublock/_locales/fa/messages.json +1 -1
- package/extensions/ublock/_locales/fi/messages.json +6 -6
- package/extensions/ublock/_locales/hr/messages.json +4 -4
- package/extensions/ublock/_locales/nb/messages.json +1 -1
- package/extensions/ublock/_locales/no/messages.json +1 -1
- package/extensions/ublock/_locales/ro/messages.json +2 -2
- package/extensions/ublock/_locales/ru/messages.json +1 -1
- package/extensions/ublock/_locales/sk/messages.json +1 -1
- package/extensions/ublock/_locales/sv/messages.json +2 -2
- package/extensions/ublock/_locales/te/messages.json +17 -17
- package/extensions/ublock/_locales/vi/messages.json +12 -12
- package/extensions/ublock/_locales/zh_TW/messages.json +13 -13
- package/extensions/ublock/assets/assets.json +3 -3
- package/extensions/ublock/assets/resources/scriptlets.js +218 -97
- package/extensions/ublock/assets/thirdparties/easylist/easylist.txt +3010 -2056
- package/extensions/ublock/assets/thirdparties/easylist/easyprivacy.txt +624 -433
- package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/serverlist +93 -24
- package/extensions/ublock/assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat +7 -15
- package/extensions/ublock/assets/thirdparties/urlhaus-filter/urlhaus-filter-online.txt +795 -777
- package/extensions/ublock/assets/ublock/badware.min.txt +138 -72
- package/extensions/ublock/assets/ublock/filters.min.txt +1929 -2735
- package/extensions/ublock/assets/ublock/privacy.min.txt +57 -26
- package/extensions/ublock/assets/ublock/quick-fixes.min.txt +125 -74
- package/extensions/ublock/assets/ublock/unbreak.min.txt +46 -53
- package/extensions/ublock/css/codemirror.css +8 -7
- package/extensions/ublock/css/dom-inspector.css +40 -0
- package/extensions/ublock/css/logger-ui-inspector.css +7 -1
- package/extensions/ublock/css/logger-ui.css +12 -5
- package/extensions/ublock/css/popup-fenix.css +1 -1
- package/extensions/ublock/devtools.html +1 -0
- package/extensions/ublock/js/1p-filters.js +4 -3
- package/extensions/ublock/js/3p-filters.js +25 -31
- package/extensions/ublock/js/about.js +1 -1
- package/extensions/ublock/js/advanced-settings.js +1 -1
- package/extensions/ublock/js/asset-viewer.js +1 -1
- package/extensions/ublock/js/assets.js +74 -44
- package/extensions/ublock/js/background.js +9 -3
- package/extensions/ublock/js/base64-custom.js +1 -1
- package/extensions/ublock/js/benchmarks.js +1 -1
- package/extensions/ublock/js/biditrie.js +1 -1
- package/extensions/ublock/js/broadcast.js +75 -0
- package/extensions/ublock/js/cachestorage.js +68 -45
- package/extensions/ublock/js/click2load.js +1 -1
- package/extensions/ublock/js/cloud-ui.js +1 -1
- package/extensions/ublock/js/code-viewer.js +1 -1
- package/extensions/ublock/js/codemirror/search-thread.js +1 -1
- package/extensions/ublock/js/codemirror/search.js +1 -1
- package/extensions/ublock/js/codemirror/ubo-dynamic-filtering.js +1 -1
- package/extensions/ublock/js/codemirror/ubo-static-filtering.js +98 -24
- package/extensions/ublock/js/commands.js +1 -1
- package/extensions/ublock/js/console.js +1 -1
- package/extensions/ublock/js/contentscript-extra.js +1 -1
- package/extensions/ublock/js/contentscript.js +1 -3
- package/extensions/ublock/js/contextmenu.js +1 -1
- package/extensions/ublock/js/cosmetic-filtering.js +4 -4
- package/extensions/ublock/js/dashboard-common.js +1 -1
- package/extensions/ublock/js/dashboard.js +1 -1
- package/extensions/ublock/js/devtools.js +23 -15
- package/extensions/ublock/js/diff-updater.js +3 -3
- package/extensions/ublock/js/document-blocked.js +1 -1
- package/extensions/ublock/js/dom-inspector.js +68 -0
- package/extensions/ublock/js/dom.js +1 -1
- package/extensions/ublock/js/dyna-rules.js +1 -1
- package/extensions/ublock/js/dynamic-net-filtering.js +1 -1
- package/extensions/ublock/js/epicker-ui.js +35 -59
- package/extensions/ublock/js/fa-icons.js +1 -1
- package/extensions/ublock/js/filtering-context.js +1 -1
- package/extensions/ublock/js/filtering-engines.js +1 -1
- package/extensions/ublock/js/hnswitches.js +1 -1
- package/extensions/ublock/js/hntrie.js +1 -1
- package/extensions/ublock/js/html-filtering.js +1 -1
- package/extensions/ublock/js/httpheader-filtering.js +1 -1
- package/extensions/ublock/js/i18n.js +1 -1
- package/extensions/ublock/js/is-webrtc-supported.js +1 -1
- package/extensions/ublock/js/logger-ui-inspector.js +203 -145
- package/extensions/ublock/js/logger-ui.js +21 -5
- package/extensions/ublock/js/logger.js +6 -2
- package/extensions/ublock/js/lz4.js +2 -2
- package/extensions/ublock/js/messaging.js +266 -166
- package/extensions/ublock/js/mrucache.js +58 -0
- package/extensions/ublock/js/pagestore.js +1 -1
- package/extensions/ublock/js/popup-fenix.js +2 -1
- package/extensions/ublock/js/redirect-engine.js +1 -1
- package/extensions/ublock/js/redirect-resources.js +1 -12
- package/extensions/ublock/js/reverselookup-worker.js +1 -1
- package/extensions/ublock/js/reverselookup.js +1 -1
- package/extensions/ublock/js/scriptlet-filtering-core.js +300 -0
- package/extensions/ublock/js/scriptlet-filtering.js +122 -350
- package/extensions/ublock/js/scriptlets/cosmetic-logger.js +36 -47
- package/extensions/ublock/js/scriptlets/cosmetic-off.js +1 -1
- package/extensions/ublock/js/scriptlets/cosmetic-on.js +1 -1
- package/extensions/ublock/js/scriptlets/cosmetic-report.js +1 -1
- package/extensions/ublock/js/scriptlets/dom-inspector.js +341 -323
- package/extensions/ublock/js/scriptlets/dom-survey-elements.js +1 -1
- package/extensions/ublock/js/scriptlets/dom-survey-scripts.js +1 -1
- package/extensions/ublock/js/scriptlets/epicker.js +80 -89
- package/extensions/ublock/js/scriptlets/load-3p-css.js +1 -1
- package/extensions/ublock/js/scriptlets/load-large-media-all.js +1 -1
- package/extensions/ublock/js/scriptlets/load-large-media-interactive.js +1 -1
- package/extensions/ublock/js/scriptlets/noscript-spoof.js +1 -1
- package/extensions/ublock/js/scriptlets/should-inject-contentscript.js +1 -1
- package/extensions/ublock/js/scriptlets/subscriber.js +1 -1
- package/extensions/ublock/js/scriptlets/updater.js +20 -3
- package/extensions/ublock/js/settings.js +1 -1
- package/extensions/ublock/js/start.js +19 -20
- package/extensions/ublock/js/static-dnr-filtering.js +1 -1
- package/extensions/ublock/js/static-ext-filtering-db.js +1 -1
- package/extensions/ublock/js/static-ext-filtering.js +1 -1
- package/extensions/ublock/js/static-filtering-io.js +1 -1
- package/extensions/ublock/js/static-filtering-parser.js +5 -3
- package/extensions/ublock/js/static-net-filtering.js +57 -37
- package/extensions/ublock/js/storage.js +49 -29
- package/extensions/ublock/js/support.js +4 -4
- package/extensions/ublock/js/tab.js +1 -1
- package/extensions/ublock/js/tasks.js +1 -1
- package/extensions/ublock/js/text-encode.js +1 -1
- package/extensions/ublock/js/text-utils.js +1 -1
- package/extensions/ublock/js/theme.js +1 -1
- package/extensions/ublock/js/traffic.js +2 -1
- package/extensions/ublock/js/ublock.js +15 -11
- package/extensions/ublock/js/uri-utils.js +1 -1
- package/extensions/ublock/js/url-net-filtering.js +1 -1
- package/extensions/ublock/js/utils.js +1 -73
- package/extensions/ublock/js/vapi-background-ext.js +1 -1
- package/extensions/ublock/js/vapi-background.js +92 -83
- package/extensions/ublock/js/vapi-client.js +4 -33
- package/extensions/ublock/js/vapi-common.js +16 -30
- package/extensions/ublock/js/vapi.js +1 -1
- package/extensions/ublock/js/wasm/biditrie.wat +1 -1
- package/extensions/ublock/js/wasm/hntrie.wat +1 -1
- package/extensions/ublock/js/webext.js +1 -1
- package/extensions/ublock/js/whitelist.js +1 -1
- package/extensions/ublock/logger-ui.html +2 -2
- package/extensions/ublock/manifest.json +1 -1
- package/extensions/ublock/support.html +0 -1
- package/extensions/ublock/web_accessible_resources/dom-inspector.html +25 -0
- package/extensions/ublock/web_accessible_resources/epicker-ui.html +0 -1
- package/extensions/ublock/web_accessible_resources/googletagservices_gpt.js +1 -0
- package/package.json +7 -19
- package/scripts/build-open-api.js +7 -4
- package/src/browserless.ts +42 -18
- package/src/browsers/index.ts +48 -20
- package/src/file-system.spec.ts +58 -0
- package/src/file-system.ts +36 -8
- package/src/http.ts +3 -3
- package/src/router.ts +2 -6
- package/src/routes/chromium/http/content-post.ts +13 -16
- package/src/routes/chromium/http/download-post.ts +16 -27
- package/src/routes/chromium/http/function-post.ts +16 -25
- package/src/routes/chromium/http/pdf-post.ts +19 -15
- package/src/routes/chromium/http/performance.ts +14 -26
- package/src/routes/chromium/http/scrape-post.ts +14 -16
- package/src/routes/chromium/http/screenshot-post.ts +18 -15
- package/src/routes/chromium/tests/websocket.spec.ts +28 -1
- package/src/routes/chromium/utils/function/handler.ts +2 -1
- package/src/routes/chromium/ws/browser.ts +10 -12
- package/src/routes/chromium/ws/cdp-chromium.ts +10 -12
- package/src/routes/chromium/ws/page.ts +10 -12
- package/src/routes/chromium/ws/playwright-chromium.ts +10 -12
- package/src/routes/firefox/ws/playwright-firefox.ts +10 -12
- package/src/routes/management/http/config-get.ts +14 -23
- package/src/routes/management/http/metrics-get.ts +15 -24
- package/src/routes/management/http/metrics-total-get.ts +15 -26
- package/src/routes/management/http/sessions-get.ts +15 -23
- package/src/routes/management/http/static-get.ts +14 -22
- package/src/routes/webkit/ws/playwright-webkit.ts +10 -12
- package/src/server.ts +0 -1
- package/src/types.ts +59 -45
- package/static/docs/browserless-logo-inline.svg +1 -0
- package/static/docs/index.html +27 -0
- package/static/docs/swagger.json +33 -33
- package/static/function/client.js +626 -78
- package/extensions/ublock/js/vapi-client-extra.js +0 -312
- package/extensions/ublock/web_accessible_resources/addthis_widget.js +0 -39
- package/extensions/ublock/web_accessible_resources/ligatus_angular-tag.js +0 -29
- package/extensions/ublock/web_accessible_resources/monkeybroker.js +0 -43
- package/extensions/ublock/web_accessible_resources/mxpnl_mixpanel.js +0 -51
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*******************************************************************************
|
|
2
2
|
|
|
3
|
-
uBlock Origin - a
|
|
3
|
+
uBlock Origin - a comprehensive, efficient content blocker
|
|
4
4
|
Copyright (C) 2014-present Raymond Hill
|
|
5
5
|
|
|
6
6
|
This program is free software: you can redistribute it and/or modify
|
|
@@ -23,11 +23,12 @@
|
|
|
23
23
|
|
|
24
24
|
/******************************************************************************/
|
|
25
25
|
|
|
26
|
-
import cacheStorage from './cachestorage.js';
|
|
27
|
-
import logger from './logger.js';
|
|
28
26
|
import µb from './background.js';
|
|
27
|
+
import { broadcast } from './broadcast.js';
|
|
28
|
+
import cacheStorage from './cachestorage.js';
|
|
29
29
|
import { ubolog } from './console.js';
|
|
30
30
|
import { i18n$ } from './i18n.js';
|
|
31
|
+
import logger from './logger.js';
|
|
31
32
|
import * as sfp from './static-filtering-parser.js';
|
|
32
33
|
import { orphanizeString, } from './text-utils.js';
|
|
33
34
|
|
|
@@ -38,6 +39,7 @@ const reIsUserAsset = /^user-/;
|
|
|
38
39
|
const errorCantConnectTo = i18n$('errorCantConnectTo');
|
|
39
40
|
const MS_PER_HOUR = 60 * 60 * 1000;
|
|
40
41
|
const MS_PER_DAY = 24 * MS_PER_HOUR;
|
|
42
|
+
const MINUTES_PER_DAY = 24 * 60;
|
|
41
43
|
const EXPIRES_DEFAULT = 7;
|
|
42
44
|
|
|
43
45
|
const assets = {};
|
|
@@ -52,7 +54,7 @@ const stringIsNotEmpty = s => typeof s === 'string' && s !== '';
|
|
|
52
54
|
|
|
53
55
|
const parseExpires = s => {
|
|
54
56
|
const matches = s.match(/(\d+)\s*([dhm]?)/i);
|
|
55
|
-
if ( matches === null ) { return
|
|
57
|
+
if ( matches === null ) { return; }
|
|
56
58
|
let updateAfter = parseInt(matches[1], 10);
|
|
57
59
|
if ( matches[2] === 'h' ) {
|
|
58
60
|
updateAfter = Math.max(updateAfter, 4) / 24;
|
|
@@ -93,31 +95,11 @@ const extractMetadataFromList = (content, fields) => {
|
|
|
93
95
|
assets.extractMetadataFromList = extractMetadataFromList;
|
|
94
96
|
|
|
95
97
|
const resourceTimeFromXhr = xhr => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
'Last-Modified'
|
|
102
|
-
]);
|
|
103
|
-
assetTime = metadata.lastModified || 0;
|
|
104
|
-
}
|
|
105
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Age
|
|
106
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date
|
|
107
|
-
let networkTime = 0;
|
|
108
|
-
if ( assetTime === 0 ) {
|
|
109
|
-
const age = parseInt(xhr.getResponseHeader('Age'), 10);
|
|
110
|
-
if ( isNaN(age) === false ) {
|
|
111
|
-
const time = (new Date(xhr.getResponseHeader('Date'))).getTime();
|
|
112
|
-
if ( isNaN(time) === false ) {
|
|
113
|
-
networkTime = time - age * 1000;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return Math.max(assetTime, networkTime, 0);
|
|
118
|
-
} catch(_) {
|
|
119
|
-
}
|
|
120
|
-
return 0;
|
|
98
|
+
if ( typeof xhr.response !== 'string' ) { return 0; }
|
|
99
|
+
const metadata = extractMetadataFromList(xhr.response, [
|
|
100
|
+
'Last-Modified'
|
|
101
|
+
]);
|
|
102
|
+
return metadata.lastModified || 0;
|
|
121
103
|
};
|
|
122
104
|
|
|
123
105
|
const resourceTimeFromParts = (parts, time) => {
|
|
@@ -174,6 +156,23 @@ const isDiffUpdatableAsset = content => {
|
|
|
174
156
|
data.diffPath.startsWith('%') === false;
|
|
175
157
|
};
|
|
176
158
|
|
|
159
|
+
const computedPatchUpdateTime = assetKey => {
|
|
160
|
+
const entry = assetCacheRegistry[assetKey];
|
|
161
|
+
if ( entry === undefined ) { return 0; }
|
|
162
|
+
if ( typeof entry.diffPath !== 'string' ) { return 0; }
|
|
163
|
+
if ( typeof entry.diffExpires !== 'number' ) { return 0; }
|
|
164
|
+
const match = /(\d+)\.(\d+)\.(\d+)\.(\d+)/.exec(entry.diffPath);
|
|
165
|
+
if ( match === null ) { return getWriteTime(); }
|
|
166
|
+
const date = new Date();
|
|
167
|
+
date.setUTCFullYear(
|
|
168
|
+
parseInt(match[1], 10),
|
|
169
|
+
parseInt(match[2], 10) - 1,
|
|
170
|
+
parseInt(match[3], 10)
|
|
171
|
+
);
|
|
172
|
+
date.setUTCHours(0, parseInt(match[4], 10) + entry.diffExpires * MINUTES_PER_DAY, 0, 0);
|
|
173
|
+
return date.getTime();
|
|
174
|
+
};
|
|
175
|
+
|
|
177
176
|
/******************************************************************************/
|
|
178
177
|
|
|
179
178
|
// favorLocal: avoid making network requests whenever possible
|
|
@@ -197,14 +196,14 @@ const getContentURLs = (assetKey, options = {}) => {
|
|
|
197
196
|
return 0;
|
|
198
197
|
});
|
|
199
198
|
}
|
|
200
|
-
if ( Array.isArray(entry.cdnURLs) ) {
|
|
199
|
+
if ( options.favorOrigin !== true && Array.isArray(entry.cdnURLs) ) {
|
|
201
200
|
const cdnURLs = entry.cdnURLs.slice();
|
|
202
201
|
for ( let i = 0, n = cdnURLs.length; i < n; i++ ) {
|
|
203
202
|
const j = Math.floor(Math.random() * n);
|
|
204
203
|
if ( j === i ) { continue; }
|
|
205
204
|
[ cdnURLs[j], cdnURLs[i] ] = [ cdnURLs[i], cdnURLs[j] ];
|
|
206
205
|
}
|
|
207
|
-
if ( options.favorLocal
|
|
206
|
+
if ( options.favorLocal ) {
|
|
208
207
|
contentURLs.push(...cdnURLs);
|
|
209
208
|
} else {
|
|
210
209
|
contentURLs.unshift(...cdnURLs);
|
|
@@ -984,6 +983,17 @@ assets.get = async function(assetKey, options = {}) {
|
|
|
984
983
|
silent: options.silent === true,
|
|
985
984
|
});
|
|
986
985
|
registerAssetSource(assetKey, { error: undefined });
|
|
986
|
+
if ( assetDetails.content === 'filters' ) {
|
|
987
|
+
const metadata = extractMetadataFromList(details.content, [
|
|
988
|
+
'Last-Modified',
|
|
989
|
+
'Expires',
|
|
990
|
+
'Diff-Name',
|
|
991
|
+
'Diff-Path',
|
|
992
|
+
'Diff-Expires',
|
|
993
|
+
]);
|
|
994
|
+
metadata.diffUpdated = undefined;
|
|
995
|
+
assetCacheSetDetails(assetKey, metadata);
|
|
996
|
+
}
|
|
987
997
|
}
|
|
988
998
|
return reportBack(details.content, contentURL);
|
|
989
999
|
}
|
|
@@ -1038,8 +1048,10 @@ async function getRemote(assetKey, options = {}) {
|
|
|
1038
1048
|
error = undefined;
|
|
1039
1049
|
|
|
1040
1050
|
// If fetched resource is older than cached one, ignore
|
|
1041
|
-
|
|
1042
|
-
|
|
1051
|
+
if ( options.favorOrigin !== true ) {
|
|
1052
|
+
stale = resourceIsStale(result, cacheDetails);
|
|
1053
|
+
if ( stale ) { continue; }
|
|
1054
|
+
}
|
|
1043
1055
|
|
|
1044
1056
|
// Success
|
|
1045
1057
|
assetCacheWrite(assetKey, {
|
|
@@ -1056,6 +1068,7 @@ async function getRemote(assetKey, options = {}) {
|
|
|
1056
1068
|
'Diff-Path',
|
|
1057
1069
|
'Diff-Expires',
|
|
1058
1070
|
]);
|
|
1071
|
+
metadata.diffUpdated = undefined;
|
|
1059
1072
|
assetCacheSetDetails(assetKey, metadata);
|
|
1060
1073
|
}
|
|
1061
1074
|
|
|
@@ -1112,6 +1125,9 @@ assets.metadata = async function() {
|
|
|
1112
1125
|
const obsoleteAfter = cacheEntry.writeTime + getUpdateAfterTime(assetKey);
|
|
1113
1126
|
assetEntry.obsolete = obsoleteAfter < now;
|
|
1114
1127
|
assetEntry.remoteURL = cacheEntry.remoteURL;
|
|
1128
|
+
if ( cacheEntry.diffUpdated ) {
|
|
1129
|
+
assetEntry.diffUpdated = cacheEntry.diffUpdated;
|
|
1130
|
+
}
|
|
1115
1131
|
} else if (
|
|
1116
1132
|
assetEntry.contentURL &&
|
|
1117
1133
|
assetEntry.contentURL.length !== 0
|
|
@@ -1153,7 +1169,7 @@ assets.getUpdateAges = async function(conditions = {}) {
|
|
|
1153
1169
|
out.push({
|
|
1154
1170
|
assetKey,
|
|
1155
1171
|
age,
|
|
1156
|
-
ageNormalized: age / getUpdateAfterTime(assetKey),
|
|
1172
|
+
ageNormalized: age / Math.max(1, getUpdateAfterTime(assetKey)),
|
|
1157
1173
|
});
|
|
1158
1174
|
}
|
|
1159
1175
|
return out;
|
|
@@ -1188,8 +1204,20 @@ const getAssetDiffDetails = assetKey => {
|
|
|
1188
1204
|
out.writeTime = cacheEntry.writeTime;
|
|
1189
1205
|
const assetEntry = assetSourceRegistry[assetKey];
|
|
1190
1206
|
if ( assetEntry === undefined ) { return; }
|
|
1191
|
-
if (
|
|
1192
|
-
|
|
1207
|
+
if ( assetEntry.content !== 'filters' ) { return; }
|
|
1208
|
+
if ( Array.isArray(assetEntry.cdnURLs) ) {
|
|
1209
|
+
out.cdnURLs = assetEntry.cdnURLs.slice();
|
|
1210
|
+
} else if ( reIsExternalPath.test(assetKey) ) {
|
|
1211
|
+
out.cdnURLs = [ assetKey ];
|
|
1212
|
+
} else if ( typeof assetEntry.contentURL === 'string' ) {
|
|
1213
|
+
out.cdnURLs = [ assetEntry.contentURL ];
|
|
1214
|
+
} else if ( Array.isArray(assetEntry.contentURL) ) {
|
|
1215
|
+
out.cdnURLs = assetEntry.contentURL.slice(0).filter(url =>
|
|
1216
|
+
reIsExternalPath.test(url)
|
|
1217
|
+
);
|
|
1218
|
+
}
|
|
1219
|
+
if ( Array.isArray(out.cdnURLs) === false ) { return; }
|
|
1220
|
+
if ( out.cdnURLs.length === 0 ) { return; }
|
|
1193
1221
|
return out;
|
|
1194
1222
|
};
|
|
1195
1223
|
|
|
@@ -1205,12 +1233,13 @@ async function diffUpdater() {
|
|
|
1205
1233
|
const assetDetails = getAssetDiffDetails(assetKey);
|
|
1206
1234
|
if ( assetDetails === undefined ) { continue; }
|
|
1207
1235
|
assetDetails.what = 'update';
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
toSoftUpdate.push(assetDetails);
|
|
1211
|
-
} else {
|
|
1236
|
+
const computedUpdateTime = computedPatchUpdateTime(assetKey);
|
|
1237
|
+
if ( computedUpdateTime !== 0 && computedUpdateTime <= now ) {
|
|
1212
1238
|
assetDetails.fetch = true;
|
|
1213
1239
|
toHardUpdate.push(assetDetails);
|
|
1240
|
+
} else {
|
|
1241
|
+
assetDetails.fetch = false;
|
|
1242
|
+
toSoftUpdate.push(assetDetails);
|
|
1214
1243
|
}
|
|
1215
1244
|
}
|
|
1216
1245
|
if ( toHardUpdate.length === 0 ) { return; }
|
|
@@ -1234,7 +1263,7 @@ async function diffUpdater() {
|
|
|
1234
1263
|
assetCacheSetDetails(data.assetKey, metadata);
|
|
1235
1264
|
};
|
|
1236
1265
|
bc.onmessage = ev => {
|
|
1237
|
-
const data = ev.data;
|
|
1266
|
+
const data = ev.data || {};
|
|
1238
1267
|
if ( data.what === 'ready' ) {
|
|
1239
1268
|
ubolog('Diff updater: hard updating', toHardUpdate.map(v => v.assetKey).join());
|
|
1240
1269
|
while ( toHardUpdate.length !== 0 ) {
|
|
@@ -1272,6 +1301,7 @@ async function diffUpdater() {
|
|
|
1272
1301
|
content: data.text,
|
|
1273
1302
|
resourceTime: metadata.lastModified || 0,
|
|
1274
1303
|
});
|
|
1304
|
+
metadata.diffUpdated = true;
|
|
1275
1305
|
assetCacheSetDetails(data.assetKey, metadata);
|
|
1276
1306
|
updaterUpdated.push(data.assetKey);
|
|
1277
1307
|
} else if ( data.error ) {
|
|
@@ -1279,7 +1309,7 @@ async function diffUpdater() {
|
|
|
1279
1309
|
} else if ( data.status === 'nopatch-yet' || data.status === 'nodiff' ) {
|
|
1280
1310
|
ubolog(`Diff updater: skip update of ${data.assetKey} using ${data.patchPath}\n\treason: ${data.status}`);
|
|
1281
1311
|
assetCacheSetDetails(data.assetKey, { writeTime: data.writeTime });
|
|
1282
|
-
|
|
1312
|
+
broadcast({
|
|
1283
1313
|
what: 'assetUpdated',
|
|
1284
1314
|
key: data.assetKey,
|
|
1285
1315
|
cached: true,
|
|
@@ -1415,8 +1445,8 @@ function updateDone() {
|
|
|
1415
1445
|
|
|
1416
1446
|
assets.updateStart = function(details) {
|
|
1417
1447
|
const oldUpdateDelay = updaterAssetDelay;
|
|
1418
|
-
const newUpdateDelay = typeof details.
|
|
1419
|
-
? details.
|
|
1448
|
+
const newUpdateDelay = typeof details.fetchDelay === 'number'
|
|
1449
|
+
? details.fetchDelay
|
|
1420
1450
|
: updaterAssetDelayDefault;
|
|
1421
1451
|
updaterAssetDelay = Math.min(oldUpdateDelay, newUpdateDelay);
|
|
1422
1452
|
updaterAuto = details.auto === true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*******************************************************************************
|
|
2
2
|
|
|
3
|
-
uBlock Origin - a
|
|
3
|
+
uBlock Origin - a comprehensive, efficient content blocker
|
|
4
4
|
Copyright (C) 2014-present Raymond Hill
|
|
5
5
|
|
|
6
6
|
This program is free software: you can redistribute it and/or modify
|
|
@@ -144,10 +144,12 @@ if ( vAPI.webextFlavor.soup.has('firefox') ) {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
const µBlock = { // jshint ignore:line
|
|
147
|
-
|
|
147
|
+
wakeupReason: '',
|
|
148
|
+
|
|
149
|
+
userSettingsDefault,
|
|
148
150
|
userSettings: Object.assign({}, userSettingsDefault),
|
|
149
151
|
|
|
150
|
-
hiddenSettingsDefault
|
|
152
|
+
hiddenSettingsDefault,
|
|
151
153
|
hiddenSettingsAdmin: {},
|
|
152
154
|
hiddenSettings: Object.assign({}, hiddenSettingsDefault),
|
|
153
155
|
|
|
@@ -268,6 +270,10 @@ const µBlock = { // jshint ignore:line
|
|
|
268
270
|
uiAccentStylesheet: '',
|
|
269
271
|
};
|
|
270
272
|
|
|
273
|
+
µBlock.isReadyPromise = new Promise(resolve => {
|
|
274
|
+
µBlock.isReadyResolve = resolve;
|
|
275
|
+
});
|
|
276
|
+
|
|
271
277
|
µBlock.domainFromHostname = domainFromHostname;
|
|
272
278
|
µBlock.hostnameFromURI = hostnameFromURI;
|
|
273
279
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*******************************************************************************
|
|
2
2
|
|
|
3
|
-
uBlock Origin - a
|
|
3
|
+
uBlock Origin - a comprehensive, efficient content blocker
|
|
4
4
|
Copyright (C) 2014-present Raymond Hill
|
|
5
5
|
|
|
6
6
|
This program is free software: you can redistribute it and/or modify
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*******************************************************************************
|
|
2
2
|
|
|
3
|
-
uBlock Origin - a
|
|
3
|
+
uBlock Origin - a comprehensive, efficient content blocker
|
|
4
4
|
Copyright (C) 2014-present Raymond Hill
|
|
5
5
|
|
|
6
6
|
This program is free software: you can redistribute it and/or modify
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*******************************************************************************
|
|
2
2
|
|
|
3
|
-
uBlock Origin - a
|
|
3
|
+
uBlock Origin - a comprehensive, efficient content blocker
|
|
4
4
|
Copyright (C) 2019-present Raymond Hill
|
|
5
5
|
|
|
6
6
|
This program is free software: you can redistribute it and/or modify
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*******************************************************************************
|
|
2
|
+
|
|
3
|
+
uBlock Origin - a comprehensive, efficient content blocker
|
|
4
|
+
Copyright (C) 2014-present Raymond Hill
|
|
5
|
+
|
|
6
|
+
This program is free software: you can redistribute it and/or modify
|
|
7
|
+
it under the terms of the GNU General Public License as published by
|
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
(at your option) any later version.
|
|
10
|
+
|
|
11
|
+
This program is distributed in the hope that it will be useful,
|
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
GNU General Public License for more details.
|
|
15
|
+
|
|
16
|
+
You should have received a copy of the GNU General Public License
|
|
17
|
+
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
|
18
|
+
|
|
19
|
+
Home: https://github.com/gorhill/uBlock
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/* globals browser */
|
|
23
|
+
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
/******************************************************************************/
|
|
27
|
+
|
|
28
|
+
// Broadcast a message to all uBO contexts
|
|
29
|
+
|
|
30
|
+
let broadcastChannel;
|
|
31
|
+
|
|
32
|
+
export function broadcast(message) {
|
|
33
|
+
if ( broadcastChannel === undefined ) {
|
|
34
|
+
broadcastChannel = new self.BroadcastChannel('uBO');
|
|
35
|
+
}
|
|
36
|
+
broadcastChannel.postMessage(message);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/******************************************************************************/
|
|
40
|
+
|
|
41
|
+
// Broadcast a message to all uBO contexts and all uBO's content scripts
|
|
42
|
+
|
|
43
|
+
export async function broadcastToAll(message) {
|
|
44
|
+
broadcast(message);
|
|
45
|
+
const tabs = await vAPI.tabs.query({
|
|
46
|
+
discarded: false,
|
|
47
|
+
});
|
|
48
|
+
const bcmessage = Object.assign({ broadcast: true }, message);
|
|
49
|
+
for ( const tab of tabs ) {
|
|
50
|
+
browser.tabs.sendMessage(tab.id, bcmessage);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/******************************************************************************/
|
|
55
|
+
|
|
56
|
+
export function onBroadcast(listener) {
|
|
57
|
+
const bc = new self.BroadcastChannel('uBO');
|
|
58
|
+
bc.onmessage = ev => listener(ev.data || {});
|
|
59
|
+
return bc;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/******************************************************************************/
|
|
63
|
+
|
|
64
|
+
export function filteringBehaviorChanged(details = {}) {
|
|
65
|
+
if ( typeof details.direction !== 'number' || details.direction >= 0 ) {
|
|
66
|
+
filteringBehaviorChanged.throttle.offon(727);
|
|
67
|
+
}
|
|
68
|
+
broadcast(Object.assign({ what: 'filteringBehaviorChanged' }, details));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
filteringBehaviorChanged.throttle = vAPI.defer.create(( ) => {
|
|
72
|
+
vAPI.net.handlerBehaviorChanged();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/******************************************************************************/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*******************************************************************************
|
|
2
2
|
|
|
3
|
-
uBlock Origin - a
|
|
3
|
+
uBlock Origin - a comprehensive, efficient content blocker
|
|
4
4
|
Copyright (C) 2016-present The uBlock Origin authors
|
|
5
5
|
|
|
6
6
|
This program is free software: you can redistribute it and/or modify
|
|
@@ -61,27 +61,40 @@ const STORAGE_NAME = 'uBlock0CacheStorage';
|
|
|
61
61
|
// Default to webext storage.
|
|
62
62
|
const storageLocal = webext.storage.local;
|
|
63
63
|
|
|
64
|
+
let storageReadyResolve;
|
|
65
|
+
const storageReadyPromise = new Promise(resolve => {
|
|
66
|
+
storageReadyResolve = resolve;
|
|
67
|
+
});
|
|
68
|
+
|
|
64
69
|
const cacheStorage = {
|
|
65
70
|
name: 'browser.storage.local',
|
|
66
71
|
get(...args) {
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
return storageReadyPromise.then(( ) =>
|
|
73
|
+
storageLocal.get(...args).catch(reason => {
|
|
74
|
+
console.log(reason);
|
|
75
|
+
})
|
|
76
|
+
);
|
|
70
77
|
},
|
|
71
78
|
set(...args) {
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
return storageReadyPromise.then(( ) =>
|
|
80
|
+
storageLocal.set(...args).catch(reason => {
|
|
81
|
+
console.log(reason);
|
|
82
|
+
})
|
|
83
|
+
);
|
|
75
84
|
},
|
|
76
85
|
remove(...args) {
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
return storageReadyPromise.then(( ) =>
|
|
87
|
+
storageLocal.remove(...args).catch(reason => {
|
|
88
|
+
console.log(reason);
|
|
89
|
+
})
|
|
90
|
+
);
|
|
80
91
|
},
|
|
81
92
|
clear(...args) {
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
return storageReadyPromise.then(( ) =>
|
|
94
|
+
storageLocal.clear(...args).catch(reason => {
|
|
95
|
+
console.log(reason);
|
|
96
|
+
})
|
|
97
|
+
);
|
|
85
98
|
},
|
|
86
99
|
select: function(selectedBackend) {
|
|
87
100
|
let actualBackend = selectedBackend;
|
|
@@ -94,15 +107,18 @@ const cacheStorage = {
|
|
|
94
107
|
return selectIDB().then(success => {
|
|
95
108
|
if ( success || selectedBackend === 'indexedDB' ) {
|
|
96
109
|
clearWebext();
|
|
110
|
+
storageReadyResolve();
|
|
97
111
|
return 'indexedDB';
|
|
98
112
|
}
|
|
99
113
|
clearIDB();
|
|
114
|
+
storageReadyResolve();
|
|
100
115
|
return 'browser.storage.local';
|
|
101
116
|
});
|
|
102
117
|
}
|
|
103
118
|
if ( actualBackend === 'browser.storage.local' ) {
|
|
104
119
|
clearIDB();
|
|
105
120
|
}
|
|
121
|
+
storageReadyResolve();
|
|
106
122
|
return Promise.resolve('browser.storage.local');
|
|
107
123
|
|
|
108
124
|
},
|
|
@@ -435,36 +451,44 @@ const selectIDB = async function() {
|
|
|
435
451
|
|
|
436
452
|
cacheStorage.name = 'indexedDB';
|
|
437
453
|
cacheStorage.get = function get(keys) {
|
|
438
|
-
return
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
454
|
+
return storageReadyPromise.then(( ) =>
|
|
455
|
+
new Promise(resolve => {
|
|
456
|
+
if ( keys === null ) {
|
|
457
|
+
return getAllFromDb(bin => resolve(bin));
|
|
458
|
+
}
|
|
459
|
+
let toRead, output = {};
|
|
460
|
+
if ( typeof keys === 'string' ) {
|
|
461
|
+
toRead = [ keys ];
|
|
462
|
+
} else if ( Array.isArray(keys) ) {
|
|
463
|
+
toRead = keys;
|
|
464
|
+
} else /* if ( typeof keys === 'object' ) */ {
|
|
465
|
+
toRead = Object.keys(keys);
|
|
466
|
+
output = keys;
|
|
467
|
+
}
|
|
468
|
+
getFromDb(toRead, output, bin => resolve(bin));
|
|
469
|
+
})
|
|
470
|
+
);
|
|
453
471
|
};
|
|
454
472
|
cacheStorage.set = function set(keys) {
|
|
455
|
-
return
|
|
456
|
-
|
|
457
|
-
|
|
473
|
+
return storageReadyPromise.then(( ) =>
|
|
474
|
+
new Promise(resolve => {
|
|
475
|
+
putToDb(keys, details => resolve(details));
|
|
476
|
+
})
|
|
477
|
+
);
|
|
458
478
|
};
|
|
459
479
|
cacheStorage.remove = function remove(keys) {
|
|
460
|
-
return
|
|
461
|
-
|
|
462
|
-
|
|
480
|
+
return storageReadyPromise.then(( ) =>
|
|
481
|
+
new Promise(resolve => {
|
|
482
|
+
deleteFromDb(keys, ( ) => resolve());
|
|
483
|
+
})
|
|
484
|
+
);
|
|
463
485
|
};
|
|
464
486
|
cacheStorage.clear = function clear() {
|
|
465
|
-
return
|
|
466
|
-
|
|
467
|
-
|
|
487
|
+
return storageReadyPromise.then(( ) =>
|
|
488
|
+
new Promise(resolve => {
|
|
489
|
+
clearDb(( ) => resolve());
|
|
490
|
+
})
|
|
491
|
+
);
|
|
468
492
|
};
|
|
469
493
|
cacheStorage.getBytesInUse = function getBytesInUse() {
|
|
470
494
|
return Promise.resolve(0);
|
|
@@ -475,18 +499,17 @@ const selectIDB = async function() {
|
|
|
475
499
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/328
|
|
476
500
|
// Delete cache-related entries from webext storage.
|
|
477
501
|
const clearWebext = async function() {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
bin
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
return;
|
|
502
|
+
let bin;
|
|
503
|
+
try {
|
|
504
|
+
bin = await webext.storage.local.get('assetCacheRegistry');
|
|
505
|
+
} catch(ex) {
|
|
506
|
+
console.error(ex);
|
|
484
507
|
}
|
|
508
|
+
if ( bin instanceof Object === false ) { return; }
|
|
509
|
+
if ( bin.assetCacheRegistry instanceof Object === false ) { return; }
|
|
485
510
|
const toRemove = [
|
|
486
511
|
'assetCacheRegistry',
|
|
487
512
|
'assetSourceRegistry',
|
|
488
|
-
'resourcesSelfie',
|
|
489
|
-
'selfie'
|
|
490
513
|
];
|
|
491
514
|
for ( const key in bin.assetCacheRegistry ) {
|
|
492
515
|
if ( bin.assetCacheRegistry.hasOwnProperty(key) ) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*******************************************************************************
|
|
2
2
|
|
|
3
|
-
uBlock Origin - a
|
|
3
|
+
uBlock Origin - a comprehensive, efficient content blocker
|
|
4
4
|
Copyright (C) 2014-present Raymond Hill
|
|
5
5
|
|
|
6
6
|
This program is free software: you can redistribute it and/or modify
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*******************************************************************************
|
|
2
2
|
|
|
3
|
-
uBlock Origin - a
|
|
3
|
+
uBlock Origin - a comprehensive, efficient content blocker
|
|
4
4
|
Copyright (C) 2015-2018 Raymond Hill
|
|
5
5
|
|
|
6
6
|
This program is free software: you can redistribute it and/or modify
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*******************************************************************************
|
|
2
2
|
|
|
3
|
-
uBlock Origin - a
|
|
3
|
+
uBlock Origin - a comprehensive, efficient content blocker
|
|
4
4
|
Copyright (C) 2023-present Raymond Hill
|
|
5
5
|
|
|
6
6
|
This program is free software: you can redistribute it and/or modify
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*******************************************************************************
|
|
2
2
|
|
|
3
|
-
uBlock Origin - a
|
|
3
|
+
uBlock Origin - a comprehensive, efficient content blocker
|
|
4
4
|
Copyright (C) 2020-present Raymond Hill
|
|
5
5
|
|
|
6
6
|
This program is free software: you can redistribute it and/or modify
|
|
@@ -377,7 +377,7 @@ import { i18n$ } from '../i18n.js';
|
|
|
377
377
|
if ( markers === null ) { return; }
|
|
378
378
|
const marker = markers['CodeMirror-lintgutter'];
|
|
379
379
|
if ( marker === undefined ) { return; }
|
|
380
|
-
if ( marker.dataset.
|
|
380
|
+
if ( marker.dataset.error !== 'y' ) { return; }
|
|
381
381
|
const line = lineHandle.lineNo();
|
|
382
382
|
if ( dir < 0 ) {
|
|
383
383
|
found = line;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*******************************************************************************
|
|
2
2
|
|
|
3
|
-
uBlock Origin - a
|
|
3
|
+
uBlock Origin - a comprehensive, efficient content blocker
|
|
4
4
|
Copyright (C) 2019-present Raymond Hill
|
|
5
5
|
|
|
6
6
|
This program is free software: you can redistribute it and/or modify
|