@browserless.io/browserless 2.20.2 → 2.21.1
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 +15 -1
- package/bin/browserless.js +2 -1
- package/build/browserless.js +3 -2
- package/build/browsers/index.d.ts +3 -2
- package/build/browsers/index.js +3 -1
- 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 +8 -8
- package/build/routes/chrome/tests/pdf.spec.js +24 -12
- 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 +8 -8
- package/build/routes/chromium/tests/pdf.spec.js +24 -12
- package/build/shared/pdf.http.js +10 -5
- package/docker/sdk/Dockerfile +11 -0
- package/extensions/ublock/_locales/ar/messages.json +5 -1
- package/extensions/ublock/_locales/az/messages.json +4 -0
- package/extensions/ublock/_locales/be/messages.json +4 -0
- package/extensions/ublock/_locales/bg/messages.json +4 -0
- package/extensions/ublock/_locales/bn/messages.json +4 -0
- package/extensions/ublock/_locales/br_FR/messages.json +9 -5
- package/extensions/ublock/_locales/bs/messages.json +4 -0
- package/extensions/ublock/_locales/ca/messages.json +5 -1
- package/extensions/ublock/_locales/cs/messages.json +4 -0
- package/extensions/ublock/_locales/cv/messages.json +4 -0
- package/extensions/ublock/_locales/cy/messages.json +4 -0
- package/extensions/ublock/_locales/da/messages.json +4 -0
- package/extensions/ublock/_locales/de/messages.json +4 -0
- package/extensions/ublock/_locales/el/messages.json +8 -4
- package/extensions/ublock/_locales/en/messages.json +4 -0
- package/extensions/ublock/_locales/en_GB/messages.json +4 -0
- package/extensions/ublock/_locales/eo/messages.json +9 -5
- package/extensions/ublock/_locales/es/messages.json +4 -0
- package/extensions/ublock/_locales/et/messages.json +4 -0
- package/extensions/ublock/_locales/eu/messages.json +4 -0
- package/extensions/ublock/_locales/fa/messages.json +4 -0
- package/extensions/ublock/_locales/fi/messages.json +6 -2
- package/extensions/ublock/_locales/fil/messages.json +4 -0
- package/extensions/ublock/_locales/fr/messages.json +4 -0
- package/extensions/ublock/_locales/fy/messages.json +4 -0
- package/extensions/ublock/_locales/gl/messages.json +12 -8
- package/extensions/ublock/_locales/gu/messages.json +4 -0
- package/extensions/ublock/_locales/he/messages.json +4 -0
- package/extensions/ublock/_locales/hi/messages.json +4 -0
- package/extensions/ublock/_locales/hr/messages.json +4 -0
- package/extensions/ublock/_locales/hu/messages.json +68 -64
- package/extensions/ublock/_locales/hy/messages.json +4 -0
- package/extensions/ublock/_locales/id/messages.json +6 -2
- package/extensions/ublock/_locales/it/messages.json +4 -0
- package/extensions/ublock/_locales/ja/messages.json +4 -0
- package/extensions/ublock/_locales/ka/messages.json +4 -0
- package/extensions/ublock/_locales/kk/messages.json +4 -0
- package/extensions/ublock/_locales/kn/messages.json +4 -0
- package/extensions/ublock/_locales/ko/messages.json +4 -0
- package/extensions/ublock/_locales/lt/messages.json +4 -0
- package/extensions/ublock/_locales/lv/messages.json +4 -0
- package/extensions/ublock/_locales/mk/messages.json +4 -0
- package/extensions/ublock/_locales/ml/messages.json +4 -0
- package/extensions/ublock/_locales/mr/messages.json +4 -0
- package/extensions/ublock/_locales/ms/messages.json +4 -0
- package/extensions/ublock/_locales/nb/messages.json +4 -0
- package/extensions/ublock/_locales/nl/messages.json +4 -0
- package/extensions/ublock/_locales/no/messages.json +4 -0
- package/extensions/ublock/_locales/oc/messages.json +4 -0
- package/extensions/ublock/_locales/pa/messages.json +8 -4
- package/extensions/ublock/_locales/pl/messages.json +4 -0
- package/extensions/ublock/_locales/pt_BR/messages.json +4 -0
- package/extensions/ublock/_locales/pt_PT/messages.json +4 -0
- package/extensions/ublock/_locales/ro/messages.json +4 -0
- package/extensions/ublock/_locales/ru/messages.json +4 -0
- package/extensions/ublock/_locales/si/messages.json +4 -0
- package/extensions/ublock/_locales/sk/messages.json +4 -0
- package/extensions/ublock/_locales/sl/messages.json +4 -0
- package/extensions/ublock/_locales/so/messages.json +4 -0
- package/extensions/ublock/_locales/sq/messages.json +4 -0
- package/extensions/ublock/_locales/sr/messages.json +6 -2
- package/extensions/ublock/_locales/sv/messages.json +4 -0
- package/extensions/ublock/_locales/sw/messages.json +4 -0
- package/extensions/ublock/_locales/ta/messages.json +4 -0
- package/extensions/ublock/_locales/te/messages.json +4 -0
- package/extensions/ublock/_locales/th/messages.json +4 -0
- package/extensions/ublock/_locales/tr/messages.json +4 -0
- package/extensions/ublock/_locales/uk/messages.json +4 -0
- package/extensions/ublock/_locales/ur/messages.json +4 -0
- package/extensions/ublock/_locales/vi/messages.json +4 -0
- package/extensions/ublock/_locales/zh_CN/messages.json +4 -0
- package/extensions/ublock/_locales/zh_TW/messages.json +5 -1
- package/extensions/ublock/assets/assets.json +8 -6
- package/extensions/ublock/assets/resources/scriptlets.js +455 -301
- package/extensions/ublock/assets/thirdparties/easylist/easylist.txt +4441 -6643
- package/extensions/ublock/assets/thirdparties/easylist/easyprivacy.txt +401 -307
- package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/serverlist +34 -29
- package/extensions/ublock/assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat +682 -709
- package/extensions/ublock/assets/thirdparties/urlhaus-filter/urlhaus-filter-online.txt +2439 -1999
- package/extensions/ublock/assets/ublock/badlists.txt +7 -0
- package/extensions/ublock/assets/ublock/badware.min.txt +992 -552
- package/extensions/ublock/assets/ublock/filters.min.txt +1253 -864
- package/extensions/ublock/assets/ublock/privacy.min.txt +58 -31
- package/extensions/ublock/assets/ublock/quick-fixes.min.txt +118 -126
- package/extensions/ublock/assets/ublock/unbreak.min.txt +129 -109
- package/extensions/ublock/js/background.js +4 -3
- package/extensions/ublock/js/benchmarks.js +29 -29
- package/extensions/ublock/js/codemirror/ubo-static-filtering.js +1 -0
- package/extensions/ublock/js/contextmenu.js +20 -21
- package/extensions/ublock/js/devtools.js +137 -3
- package/extensions/ublock/js/filtering-context.js +98 -43
- package/extensions/ublock/js/logger-ui.js +1 -1
- package/extensions/ublock/js/messaging.js +57 -135
- package/extensions/ublock/js/pagestore.js +44 -31
- package/extensions/ublock/js/redirect-resources.js +14 -4
- package/extensions/ublock/js/scriptlet-filtering.js +4 -1
- package/extensions/ublock/js/static-filtering-parser.js +107 -37
- package/extensions/ublock/js/static-net-filtering.js +514 -250
- package/extensions/ublock/js/storage.js +2 -1
- package/extensions/ublock/js/traffic.js +8 -4
- package/extensions/ublock/js/vapi-background.js +1 -0
- package/extensions/ublock/js/vapi-common.js +1 -0
- package/extensions/ublock/logger-ui.html +2 -3
- package/extensions/ublock/manifest.json +2 -2
- package/extensions/ublock/support.html +1 -0
- package/extensions/ublock/web_accessible_resources/noop-vast2.xml +1 -0
- package/extensions/ublock/web_accessible_resources/noop-vast3.xml +1 -0
- package/extensions/ublock/web_accessible_resources/noop-vast4.xml +1 -0
- package/package.json +17 -17
- package/src/browserless.ts +3 -2
- package/src/browsers/index.ts +2 -0
- package/src/routes/chrome/tests/pdf.spec.ts +24 -12
- package/src/routes/chromium/tests/pdf.spec.ts +24 -12
- package/src/shared/pdf.http.ts +10 -6
- package/static/docs/swagger.json +10 -10
- package/static/docs/swagger.min.json +9 -9
- package/static/function/client.js +9 -9
- package/static/function/index.html +9 -9
- /package/extensions/ublock/web_accessible_resources/{noop-vmap1.0.xml → noop-vmap1.xml} +0 -0
|
@@ -59,15 +59,15 @@ const hiddenSettingsDefault = {
|
|
|
59
59
|
cnameIgnore1stParty: true,
|
|
60
60
|
cnameIgnoreExceptions: true,
|
|
61
61
|
cnameIgnoreRootDocument: true,
|
|
62
|
-
cnameMaxTTL: 120,
|
|
63
62
|
cnameReplayFullURL: false,
|
|
64
|
-
cnameUncloakProxied: false,
|
|
65
63
|
consoleLogLevel: 'unset',
|
|
66
64
|
debugAssetsJson: false,
|
|
67
65
|
debugScriptlets: false,
|
|
68
66
|
debugScriptletInjector: false,
|
|
69
67
|
differentialUpdate: true,
|
|
70
68
|
disableWebAssembly: false,
|
|
69
|
+
dnsCacheTTL: 600,
|
|
70
|
+
dnsResolveEnabled: true,
|
|
71
71
|
extensionUpdateForceReload: false,
|
|
72
72
|
filterAuthorMode: false,
|
|
73
73
|
loggerPopupType: 'popup',
|
|
@@ -306,6 +306,7 @@ const µBlock = { // jshint ignore:line
|
|
|
306
306
|
this.realm = '';
|
|
307
307
|
this.setMethod(details.method);
|
|
308
308
|
this.setURL(details.url);
|
|
309
|
+
this.setIPAddress(details.ip);
|
|
309
310
|
this.aliasURL = details.aliasURL || undefined;
|
|
310
311
|
this.redirectURL = undefined;
|
|
311
312
|
this.filter = undefined;
|
|
@@ -346,7 +347,7 @@ const µBlock = { // jshint ignore:line
|
|
|
346
347
|
this.setDocOrigin(origin).setTabOrigin(origin);
|
|
347
348
|
return this;
|
|
348
349
|
}
|
|
349
|
-
const origin =
|
|
350
|
+
const origin = this.isDocument()
|
|
350
351
|
? originFromURI(this.url)
|
|
351
352
|
: this.tabOrigin;
|
|
352
353
|
this.setDocOrigin(origin).setTabOrigin(origin);
|
|
@@ -19,26 +19,22 @@
|
|
|
19
19
|
Home: https://github.com/gorhill/uBlock
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
'use strict';
|
|
23
|
-
|
|
24
|
-
/******************************************************************************/
|
|
25
|
-
|
|
26
|
-
import cosmeticFilteringEngine from './cosmetic-filtering.js';
|
|
27
|
-
import io from './assets.js';
|
|
28
|
-
import scriptletFilteringEngine from './scriptlet-filtering.js';
|
|
29
|
-
import staticNetFilteringEngine from './static-net-filtering.js';
|
|
30
|
-
import µb from './background.js';
|
|
31
|
-
import webRequest from './traffic.js';
|
|
32
|
-
import { FilteringContext } from './filtering-context.js';
|
|
33
|
-
import { LineIterator } from './text-utils.js';
|
|
34
|
-
import { sessionFirewall } from './filtering-engines.js';
|
|
35
|
-
|
|
36
22
|
import {
|
|
37
23
|
domainFromHostname,
|
|
38
24
|
entityFromDomain,
|
|
39
25
|
hostnameFromURI,
|
|
40
26
|
} from './uri-utils.js';
|
|
41
27
|
|
|
28
|
+
import { FilteringContext } from './filtering-context.js';
|
|
29
|
+
import { LineIterator } from './text-utils.js';
|
|
30
|
+
import cosmeticFilteringEngine from './cosmetic-filtering.js';
|
|
31
|
+
import io from './assets.js';
|
|
32
|
+
import scriptletFilteringEngine from './scriptlet-filtering.js';
|
|
33
|
+
import { sessionFirewall } from './filtering-engines.js';
|
|
34
|
+
import { default as sfne } from './static-net-filtering.js';
|
|
35
|
+
import webRequest from './traffic.js';
|
|
36
|
+
import µb from './background.js';
|
|
37
|
+
|
|
42
38
|
/******************************************************************************/
|
|
43
39
|
|
|
44
40
|
// The requests.json.gz file can be downloaded from:
|
|
@@ -134,8 +130,6 @@ const loadBenchmarkDataset = (( ) => {
|
|
|
134
130
|
|
|
135
131
|
/******************************************************************************/
|
|
136
132
|
|
|
137
|
-
// action: 1=test
|
|
138
|
-
|
|
139
133
|
export async function benchmarkStaticNetFiltering(options = {}) {
|
|
140
134
|
const { target, redirectEngine } = options;
|
|
141
135
|
|
|
@@ -155,13 +149,13 @@ export async function benchmarkStaticNetFiltering(options = {}) {
|
|
|
155
149
|
fctxt.setURL(request.url);
|
|
156
150
|
fctxt.setDocOriginFromURL(request.frameUrl);
|
|
157
151
|
fctxt.setType(request.cpt);
|
|
158
|
-
const r =
|
|
152
|
+
const r = sfne.matchRequest(fctxt);
|
|
159
153
|
console.info(`Result=${r}:`);
|
|
160
154
|
console.info(`\ttype=${fctxt.type}`);
|
|
161
155
|
console.info(`\turl=${fctxt.url}`);
|
|
162
156
|
console.info(`\tdocOrigin=${fctxt.getDocOrigin()}`);
|
|
163
157
|
if ( r !== 0 ) {
|
|
164
|
-
console.info(
|
|
158
|
+
console.info(sfne.toLogData());
|
|
165
159
|
}
|
|
166
160
|
return;
|
|
167
161
|
}
|
|
@@ -178,39 +172,45 @@ export async function benchmarkStaticNetFiltering(options = {}) {
|
|
|
178
172
|
for ( let i = 0; i < requests.length; i++ ) {
|
|
179
173
|
const request = requests[i];
|
|
180
174
|
fctxt.setURL(request.url);
|
|
175
|
+
if ( fctxt.getIPAddress() === '' ) {
|
|
176
|
+
fctxt.setIPAddress('93.184.215.14\n2606:2800:21f:cb07:6820:80da:af6b:8b2c');
|
|
177
|
+
}
|
|
181
178
|
fctxt.setDocOriginFromURL(request.frameUrl);
|
|
182
179
|
fctxt.setType(request.cpt);
|
|
183
|
-
|
|
184
|
-
const r =
|
|
180
|
+
sfne.redirectURL = undefined;
|
|
181
|
+
const r = sfne.matchRequest(fctxt);
|
|
185
182
|
matchCount += 1;
|
|
186
183
|
if ( r === 1 ) { blockCount += 1; }
|
|
187
184
|
else if ( r === 2 ) { allowCount += 1; }
|
|
188
185
|
if ( r !== 1 ) {
|
|
189
|
-
if (
|
|
186
|
+
if ( sfne.transformRequest(fctxt) ) {
|
|
190
187
|
redirectCount += 1;
|
|
191
188
|
}
|
|
192
|
-
if ( fctxt.redirectURL !== undefined &&
|
|
193
|
-
if (
|
|
189
|
+
if ( fctxt.redirectURL !== undefined && sfne.hasQuery(fctxt) ) {
|
|
190
|
+
if ( sfne.filterQuery(fctxt, 'removeparam') ) {
|
|
194
191
|
removeparamCount += 1;
|
|
195
192
|
}
|
|
196
193
|
}
|
|
197
194
|
if ( fctxt.type === 'main_frame' || fctxt.type === 'sub_frame' ) {
|
|
198
|
-
if (
|
|
195
|
+
if ( sfne.matchAndFetchModifiers(fctxt, 'csp') ) {
|
|
199
196
|
cspCount += 1;
|
|
200
197
|
}
|
|
201
|
-
if (
|
|
198
|
+
if ( sfne.matchAndFetchModifiers(fctxt, 'permissions') ) {
|
|
202
199
|
permissionsCount += 1;
|
|
203
200
|
}
|
|
204
201
|
}
|
|
205
|
-
|
|
206
|
-
if (
|
|
202
|
+
sfne.matchHeaders(fctxt, []);
|
|
203
|
+
if ( sfne.matchAndFetchModifiers(fctxt, 'replace') ) {
|
|
207
204
|
replaceCount += 1;
|
|
208
205
|
}
|
|
209
206
|
} else if ( redirectEngine !== undefined ) {
|
|
210
|
-
if (
|
|
207
|
+
if ( sfne.redirectRequest(redirectEngine, fctxt) ) {
|
|
211
208
|
redirectCount += 1;
|
|
212
209
|
}
|
|
213
210
|
}
|
|
211
|
+
if ( fctxt.type === 'main_frame' ) {
|
|
212
|
+
sfne.matchAndFetchModifiers(fctxt, 'urlskip');
|
|
213
|
+
}
|
|
214
214
|
}
|
|
215
215
|
const t1 = performance.now();
|
|
216
216
|
const dur = t1 - t0;
|
|
@@ -254,7 +254,7 @@ export async function tokenHistogramsfunction() {
|
|
|
254
254
|
fctxt.setURL(request.url);
|
|
255
255
|
fctxt.setDocOriginFromURL(request.frameUrl);
|
|
256
256
|
fctxt.setType(request.cpt);
|
|
257
|
-
const r =
|
|
257
|
+
const r = sfne.matchRequest(fctxt);
|
|
258
258
|
for ( let [ keyword ] of request.url.toLowerCase().matchAll(reTokens) ) {
|
|
259
259
|
const token = keyword.slice(0, 7);
|
|
260
260
|
if ( r === 0 ) {
|
|
@@ -189,6 +189,7 @@ const uBOStaticFilteringMode = (( ) => {
|
|
|
189
189
|
mode.lastNetOptionType = nodeType;
|
|
190
190
|
return 'def';
|
|
191
191
|
case sfp.NODE_TYPE_NET_OPTION_ASSIGN:
|
|
192
|
+
case sfp.NODE_TYPE_NET_OPTION_QUOTE:
|
|
192
193
|
return 'def';
|
|
193
194
|
case sfp.NODE_TYPE_NET_OPTION_VALUE:
|
|
194
195
|
if ( mode.astWalker.canGoDown() ) { break; }
|
|
@@ -19,12 +19,8 @@
|
|
|
19
19
|
Home: https://github.com/gorhill/uBlock
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
'use strict';
|
|
23
|
-
|
|
24
|
-
/******************************************************************************/
|
|
25
|
-
|
|
26
|
-
import µb from './background.js';
|
|
27
22
|
import { i18n$ } from './i18n.js';
|
|
23
|
+
import µb from './background.js';
|
|
28
24
|
|
|
29
25
|
/******************************************************************************/
|
|
30
26
|
|
|
@@ -55,18 +51,23 @@ const onBlockElement = function(details, tab) {
|
|
|
55
51
|
let src = details.frameUrl || details.srcUrl || details.linkUrl || '';
|
|
56
52
|
|
|
57
53
|
if ( !tagName ) {
|
|
58
|
-
if ( typeof details.frameUrl === 'string' ) {
|
|
54
|
+
if ( typeof details.frameUrl === 'string' && details.frameId !== 0 ) {
|
|
59
55
|
tagName = 'iframe';
|
|
56
|
+
src = details.srcUrl;
|
|
60
57
|
} else if ( typeof details.srcUrl === 'string' ) {
|
|
61
58
|
if ( details.mediaType === 'image' ) {
|
|
62
59
|
tagName = 'img';
|
|
60
|
+
src = details.srcUrl;
|
|
63
61
|
} else if ( details.mediaType === 'video' ) {
|
|
64
62
|
tagName = 'video';
|
|
63
|
+
src = details.srcUrl;
|
|
65
64
|
} else if ( details.mediaType === 'audio' ) {
|
|
66
65
|
tagName = 'audio';
|
|
66
|
+
src = details.srcUrl;
|
|
67
67
|
}
|
|
68
68
|
} else if ( typeof details.linkUrl === 'string' ) {
|
|
69
69
|
tagName = 'a';
|
|
70
|
+
src = details.linkUrl;
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -200,27 +201,25 @@ let currentBits = 0;
|
|
|
200
201
|
|
|
201
202
|
const update = function(tabId = undefined) {
|
|
202
203
|
let newBits = 0;
|
|
203
|
-
if (
|
|
204
|
-
µb.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
} else {
|
|
213
|
-
newBits |= BLOCK_RESOURCE_BIT;
|
|
204
|
+
if ( µb.userSettings.contextMenuEnabled ) {
|
|
205
|
+
const pageStore = tabId && µb.pageStoreFromTabId(tabId) || null;
|
|
206
|
+
if ( pageStore?.getNetFilteringSwitch() ) {
|
|
207
|
+
if ( µb.userFiltersAreEnabled() ) {
|
|
208
|
+
if ( pageStore.shouldApplySpecificCosmeticFilters(0) ) {
|
|
209
|
+
newBits |= BLOCK_ELEMENT_BIT;
|
|
210
|
+
} else {
|
|
211
|
+
newBits |= BLOCK_RESOURCE_BIT;
|
|
212
|
+
}
|
|
214
213
|
}
|
|
215
214
|
if ( pageStore.largeMediaCount !== 0 ) {
|
|
216
215
|
newBits |= TEMP_ALLOW_LARGE_MEDIA_BIT;
|
|
217
216
|
}
|
|
218
217
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
newBits |= VIEW_SOURCE_BIT;
|
|
218
|
+
if ( µb.hiddenSettings.filterAuthorMode ) {
|
|
219
|
+
newBits |= VIEW_SOURCE_BIT;
|
|
220
|
+
}
|
|
223
221
|
}
|
|
222
|
+
newBits |= SUBSCRIBE_TO_LIST_BIT;
|
|
224
223
|
if ( newBits === currentBits ) { return; }
|
|
225
224
|
currentBits = newBits;
|
|
226
225
|
const usedEntries = [];
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
/* global CodeMirror, uBlockDashboard */
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
import * as s14e from './s14e-serializer.js';
|
|
26
25
|
import { dom, qs$ } from './dom.js';
|
|
27
26
|
|
|
28
27
|
/******************************************************************************/
|
|
@@ -81,6 +80,100 @@ function log(text) {
|
|
|
81
80
|
cmEditor.replaceRange(text.trim() + '\n\n', { line: 0, ch: 0 });
|
|
82
81
|
}
|
|
83
82
|
|
|
83
|
+
/******************************************************************************/
|
|
84
|
+
|
|
85
|
+
function toDNRText(raw) {
|
|
86
|
+
const result = s14e.deserialize(raw);
|
|
87
|
+
if ( typeof result === 'string' ) { return result; }
|
|
88
|
+
const { network } = result;
|
|
89
|
+
const replacer = (k, v) => {
|
|
90
|
+
if ( k.startsWith('__') ) { return; }
|
|
91
|
+
if ( Array.isArray(v) ) {
|
|
92
|
+
return v.sort();
|
|
93
|
+
}
|
|
94
|
+
if ( v instanceof Object ) {
|
|
95
|
+
const sorted = {};
|
|
96
|
+
for ( const kk of Object.keys(v).sort() ) {
|
|
97
|
+
sorted[kk] = v[kk];
|
|
98
|
+
}
|
|
99
|
+
return sorted;
|
|
100
|
+
}
|
|
101
|
+
return v;
|
|
102
|
+
};
|
|
103
|
+
const isUnsupported = rule =>
|
|
104
|
+
rule._error !== undefined;
|
|
105
|
+
const isRegex = rule =>
|
|
106
|
+
rule.condition !== undefined &&
|
|
107
|
+
rule.condition.regexFilter !== undefined;
|
|
108
|
+
const isRedirect = rule =>
|
|
109
|
+
rule.action !== undefined &&
|
|
110
|
+
rule.action.type === 'redirect' &&
|
|
111
|
+
rule.action.redirect.extensionPath !== undefined;
|
|
112
|
+
const isCsp = rule =>
|
|
113
|
+
rule.action !== undefined &&
|
|
114
|
+
rule.action.type === 'modifyHeaders';
|
|
115
|
+
const isRemoveparam = rule =>
|
|
116
|
+
rule.action !== undefined &&
|
|
117
|
+
rule.action.type === 'redirect' &&
|
|
118
|
+
rule.action.redirect.transform !== undefined;
|
|
119
|
+
const { ruleset } = network;
|
|
120
|
+
const good = ruleset.filter(rule =>
|
|
121
|
+
isUnsupported(rule) === false &&
|
|
122
|
+
isRegex(rule) === false &&
|
|
123
|
+
isRedirect(rule) === false &&
|
|
124
|
+
isCsp(rule) === false &&
|
|
125
|
+
isRemoveparam(rule) === false
|
|
126
|
+
);
|
|
127
|
+
const unsupported = ruleset.filter(rule =>
|
|
128
|
+
isUnsupported(rule)
|
|
129
|
+
);
|
|
130
|
+
const regexes = ruleset.filter(rule =>
|
|
131
|
+
isUnsupported(rule) === false &&
|
|
132
|
+
isRegex(rule) &&
|
|
133
|
+
isRedirect(rule) === false &&
|
|
134
|
+
isCsp(rule) === false &&
|
|
135
|
+
isRemoveparam(rule) === false
|
|
136
|
+
);
|
|
137
|
+
const redirects = ruleset.filter(rule =>
|
|
138
|
+
isUnsupported(rule) === false &&
|
|
139
|
+
isRedirect(rule)
|
|
140
|
+
);
|
|
141
|
+
const headers = ruleset.filter(rule =>
|
|
142
|
+
isUnsupported(rule) === false &&
|
|
143
|
+
isCsp(rule)
|
|
144
|
+
);
|
|
145
|
+
const removeparams = ruleset.filter(rule =>
|
|
146
|
+
isUnsupported(rule) === false &&
|
|
147
|
+
isRemoveparam(rule)
|
|
148
|
+
);
|
|
149
|
+
const out = [
|
|
150
|
+
`dnrRulesetFromRawLists(${JSON.stringify(result.listNames, null, 2)})`,
|
|
151
|
+
`Run time: ${result.runtime} ms`,
|
|
152
|
+
`Filters count: ${network.filterCount}`,
|
|
153
|
+
`Accepted filter count: ${network.acceptedFilterCount}`,
|
|
154
|
+
`Rejected filter count: ${network.rejectedFilterCount}`,
|
|
155
|
+
`Un-DNR-able filter count: ${unsupported.length}`,
|
|
156
|
+
`Resulting DNR rule count: ${ruleset.length}`,
|
|
157
|
+
];
|
|
158
|
+
out.push(`+ Good filters (${good.length}): ${JSON.stringify(good, replacer, 2)}`);
|
|
159
|
+
out.push(`+ Regex-based filters (${regexes.length}): ${JSON.stringify(regexes, replacer, 2)}`);
|
|
160
|
+
out.push(`+ 'redirect=' filters (${redirects.length}): ${JSON.stringify(redirects, replacer, 2)}`);
|
|
161
|
+
out.push(`+ 'csp=' filters (${headers.length}): ${JSON.stringify(headers, replacer, 2)}`);
|
|
162
|
+
out.push(`+ 'removeparam=' filters (${removeparams.length}): ${JSON.stringify(removeparams, replacer, 2)}`);
|
|
163
|
+
out.push(`+ Unsupported filters (${unsupported.length}): ${JSON.stringify(unsupported, replacer, 2)}`);
|
|
164
|
+
out.push(`+ generichide exclusions (${network.generichideExclusions.length}): ${JSON.stringify(network.generichideExclusions, replacer, 2)}`);
|
|
165
|
+
if ( result.specificCosmetic ) {
|
|
166
|
+
out.push(`+ Cosmetic filters: ${result.specificCosmetic.size}`);
|
|
167
|
+
for ( const details of result.specificCosmetic ) {
|
|
168
|
+
out.push(` ${JSON.stringify(details)}`);
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
out.push(' Cosmetic filters: 0');
|
|
172
|
+
}
|
|
173
|
+
return out.join('\n');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
84
177
|
/******************************************************************************/
|
|
85
178
|
|
|
86
179
|
dom.on('#console-clear', 'click', ( ) => {
|
|
@@ -148,7 +241,7 @@ dom.on('#snfe-todnr', 'click', ev => {
|
|
|
148
241
|
vAPI.messaging.send('devTools', {
|
|
149
242
|
what: 'snfeToDNR',
|
|
150
243
|
}).then(result => {
|
|
151
|
-
log(result);
|
|
244
|
+
log(toDNRText(result));
|
|
152
245
|
dom.attr(button, 'disabled', null);
|
|
153
246
|
});
|
|
154
247
|
});
|
|
@@ -212,3 +305,44 @@ vAPI.messaging.send('dashboard', {
|
|
|
212
305
|
});
|
|
213
306
|
|
|
214
307
|
/******************************************************************************/
|
|
308
|
+
|
|
309
|
+
async function snfeQuery(lineNo, query) {
|
|
310
|
+
const doc = cmEditor.getDoc();
|
|
311
|
+
const lineHandle = doc.getLineHandle(lineNo)
|
|
312
|
+
const result = await vAPI.messaging.send('devTools', {
|
|
313
|
+
what: 'snfeQuery',
|
|
314
|
+
query
|
|
315
|
+
});
|
|
316
|
+
if ( typeof result !== 'string' ) { return; }
|
|
317
|
+
cmEditor.startOperation();
|
|
318
|
+
const nextLineNo = doc.getLineNumber(lineHandle) + 1;
|
|
319
|
+
doc.replaceRange(`${result}\n`, { line: nextLineNo, ch: 0 });
|
|
320
|
+
cmEditor.endOperation();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
cmEditor.on('beforeChange', (cm, details) => {
|
|
324
|
+
if ( details.origin !== '+input' ) { return; }
|
|
325
|
+
if ( details.text.length !== 2 ) { return; }
|
|
326
|
+
if ( details.text[1] !== '' ) { return; }
|
|
327
|
+
const lineNo = details.from.line;
|
|
328
|
+
const line = cm.getLine(lineNo);
|
|
329
|
+
if ( details.from.ch !== line.length ) { return; }
|
|
330
|
+
if ( line.startsWith('snfe?') === false ) { return; }
|
|
331
|
+
const fields = line.slice(5).split(/\s+/);
|
|
332
|
+
const query = {};
|
|
333
|
+
for ( const field of fields ) {
|
|
334
|
+
if ( /[/.]/.test(field) ) {
|
|
335
|
+
if ( query.url === undefined ) {
|
|
336
|
+
query.url = field;
|
|
337
|
+
} else if ( query.from === undefined ) {
|
|
338
|
+
query.from = field;
|
|
339
|
+
}
|
|
340
|
+
} else if ( query.type === undefined ) {
|
|
341
|
+
query.type = field;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if ( query.url === undefined ) { return; }
|
|
345
|
+
snfeQuery(lineNo, query);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
/******************************************************************************/
|
|
@@ -19,13 +19,9 @@
|
|
|
19
19
|
Home: https://github.com/gorhill/uBlock
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
'use strict';
|
|
23
|
-
|
|
24
|
-
/******************************************************************************/
|
|
25
|
-
|
|
26
22
|
import {
|
|
27
|
-
hostnameFromURI,
|
|
28
23
|
domainFromHostname,
|
|
24
|
+
hostnameFromURI,
|
|
29
25
|
originFromURI,
|
|
30
26
|
} from './uri-utils.js';
|
|
31
27
|
|
|
@@ -56,7 +52,7 @@ export const XMLHTTPREQUEST = 1 << 13;
|
|
|
56
52
|
export const INLINE_FONT = 1 << 14;
|
|
57
53
|
export const INLINE_SCRIPT = 1 << 15;
|
|
58
54
|
export const OTHER = 1 << 16;
|
|
59
|
-
export const FRAME_ANY = MAIN_FRAME | SUB_FRAME;
|
|
55
|
+
export const FRAME_ANY = MAIN_FRAME | SUB_FRAME | OBJECT;
|
|
60
56
|
export const FONT_ANY = FONT | INLINE_FONT;
|
|
61
57
|
export const INLINE_ANY = INLINE_FONT | INLINE_SCRIPT;
|
|
62
58
|
export const PING_ANY = BEACON | CSP_REPORT | PING;
|
|
@@ -126,6 +122,8 @@ const methodBitToStrMap = new Map([
|
|
|
126
122
|
[ METHOD_PUT, 'put' ],
|
|
127
123
|
]);
|
|
128
124
|
|
|
125
|
+
const reIPv4 = /^\d+\.\d+\.\d+\.\d+$/;
|
|
126
|
+
|
|
129
127
|
/******************************************************************************/
|
|
130
128
|
|
|
131
129
|
export const FilteringContext = class {
|
|
@@ -142,6 +140,7 @@ export const FilteringContext = class {
|
|
|
142
140
|
this.aliasURL = undefined;
|
|
143
141
|
this.hostname = undefined;
|
|
144
142
|
this.domain = undefined;
|
|
143
|
+
this.ipaddress = undefined;
|
|
145
144
|
this.docId = -1;
|
|
146
145
|
this.frameId = -1;
|
|
147
146
|
this.docOrigin = undefined;
|
|
@@ -164,6 +163,9 @@ export const FilteringContext = class {
|
|
|
164
163
|
this.stype = a;
|
|
165
164
|
}
|
|
166
165
|
|
|
166
|
+
isRootDocument() {
|
|
167
|
+
return (this.itype & MAIN_FRAME) !== 0;
|
|
168
|
+
}
|
|
167
169
|
isDocument() {
|
|
168
170
|
return (this.itype & FRAME_ANY) !== 0;
|
|
169
171
|
}
|
|
@@ -179,6 +181,7 @@ export const FilteringContext = class {
|
|
|
179
181
|
this.url = other.url;
|
|
180
182
|
this.hostname = other.hostname;
|
|
181
183
|
this.domain = other.domain;
|
|
184
|
+
this.ipaddress = other.ipaddress;
|
|
182
185
|
this.docId = other.docId;
|
|
183
186
|
this.frameId = other.frameId;
|
|
184
187
|
this.docOrigin = other.docOrigin;
|
|
@@ -216,7 +219,7 @@ export const FilteringContext = class {
|
|
|
216
219
|
|
|
217
220
|
setURL(a) {
|
|
218
221
|
if ( a !== this.url ) {
|
|
219
|
-
this.hostname = this.domain = undefined;
|
|
222
|
+
this.hostname = this.domain = this.ipaddress = undefined;
|
|
220
223
|
this.url = a;
|
|
221
224
|
}
|
|
222
225
|
return this;
|
|
@@ -249,6 +252,28 @@ export const FilteringContext = class {
|
|
|
249
252
|
return this;
|
|
250
253
|
}
|
|
251
254
|
|
|
255
|
+
getIPAddress() {
|
|
256
|
+
if ( this.ipaddress !== undefined ) {
|
|
257
|
+
return this.ipaddress;
|
|
258
|
+
}
|
|
259
|
+
const ipaddr = this.getHostname();
|
|
260
|
+
const c0 = ipaddr.charCodeAt(0);
|
|
261
|
+
if ( c0 === 0x5B /* [ */ ) {
|
|
262
|
+
return (this.ipaddress = ipaddr.slice(1, -1));
|
|
263
|
+
} else if ( c0 <= 0x39 && c0 >= 0x30 ) {
|
|
264
|
+
if ( reIPv4.test(ipaddr) ) {
|
|
265
|
+
return (this.ipaddress = ipaddr);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return (this.ipaddress = '');
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Must always be called *after* setURL()
|
|
272
|
+
setIPAddress(ipaddr) {
|
|
273
|
+
this.ipaddress = ipaddr || undefined;
|
|
274
|
+
return this;
|
|
275
|
+
}
|
|
276
|
+
|
|
252
277
|
getDocOrigin() {
|
|
253
278
|
if ( this.docOrigin === undefined ) {
|
|
254
279
|
this.docOrigin = this.tabOrigin;
|
|
@@ -418,42 +443,72 @@ export const FilteringContext = class {
|
|
|
418
443
|
static getMethodName(a) {
|
|
419
444
|
return methodBitToStrMap.get(a) || '';
|
|
420
445
|
}
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
/******************************************************************************/
|
|
424
446
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
447
|
+
BEACON = BEACON;
|
|
448
|
+
CSP_REPORT = CSP_REPORT;
|
|
449
|
+
FONT = FONT;
|
|
450
|
+
IMAGE = IMAGE;
|
|
451
|
+
IMAGESET = IMAGESET;
|
|
452
|
+
MAIN_FRAME = MAIN_FRAME;
|
|
453
|
+
MEDIA = MEDIA;
|
|
454
|
+
OBJECT = OBJECT;
|
|
455
|
+
OBJECT_SUBREQUEST = OBJECT_SUBREQUEST;
|
|
456
|
+
PING = PING;
|
|
457
|
+
SCRIPT = SCRIPT;
|
|
458
|
+
STYLESHEET = STYLESHEET;
|
|
459
|
+
SUB_FRAME = SUB_FRAME;
|
|
460
|
+
WEBSOCKET = WEBSOCKET;
|
|
461
|
+
XMLHTTPREQUEST = XMLHTTPREQUEST;
|
|
462
|
+
INLINE_FONT = INLINE_FONT;
|
|
463
|
+
INLINE_SCRIPT = INLINE_SCRIPT;
|
|
464
|
+
OTHER = OTHER;
|
|
465
|
+
FRAME_ANY = FRAME_ANY;
|
|
466
|
+
FONT_ANY = FONT_ANY;
|
|
467
|
+
INLINE_ANY = INLINE_ANY;
|
|
468
|
+
PING_ANY = PING_ANY;
|
|
469
|
+
SCRIPT_ANY = SCRIPT_ANY;
|
|
470
|
+
METHOD_NONE = METHOD_NONE;
|
|
471
|
+
METHOD_CONNECT = METHOD_CONNECT;
|
|
472
|
+
METHOD_DELETE = METHOD_DELETE;
|
|
473
|
+
METHOD_GET = METHOD_GET;
|
|
474
|
+
METHOD_HEAD = METHOD_HEAD;
|
|
475
|
+
METHOD_OPTIONS = METHOD_OPTIONS;
|
|
476
|
+
METHOD_PATCH = METHOD_PATCH;
|
|
477
|
+
METHOD_POST = METHOD_POST;
|
|
478
|
+
METHOD_PUT = METHOD_PUT;
|
|
479
|
+
|
|
480
|
+
static BEACON = BEACON;
|
|
481
|
+
static CSP_REPORT = CSP_REPORT;
|
|
482
|
+
static FONT = FONT;
|
|
483
|
+
static IMAGE = IMAGE;
|
|
484
|
+
static IMAGESET = IMAGESET;
|
|
485
|
+
static MAIN_FRAME = MAIN_FRAME;
|
|
486
|
+
static MEDIA = MEDIA;
|
|
487
|
+
static OBJECT = OBJECT;
|
|
488
|
+
static OBJECT_SUBREQUEST = OBJECT_SUBREQUEST;
|
|
489
|
+
static PING = PING;
|
|
490
|
+
static SCRIPT = SCRIPT;
|
|
491
|
+
static STYLESHEET = STYLESHEET;
|
|
492
|
+
static SUB_FRAME = SUB_FRAME;
|
|
493
|
+
static WEBSOCKET = WEBSOCKET;
|
|
494
|
+
static XMLHTTPREQUEST = XMLHTTPREQUEST;
|
|
495
|
+
static INLINE_FONT = INLINE_FONT;
|
|
496
|
+
static INLINE_SCRIPT = INLINE_SCRIPT;
|
|
497
|
+
static OTHER = OTHER;
|
|
498
|
+
static FRAME_ANY = FRAME_ANY;
|
|
499
|
+
static FONT_ANY = FONT_ANY;
|
|
500
|
+
static INLINE_ANY = INLINE_ANY;
|
|
501
|
+
static PING_ANY = PING_ANY;
|
|
502
|
+
static SCRIPT_ANY = SCRIPT_ANY;
|
|
503
|
+
static METHOD_NONE = METHOD_NONE;
|
|
504
|
+
static METHOD_CONNECT = METHOD_CONNECT;
|
|
505
|
+
static METHOD_DELETE = METHOD_DELETE;
|
|
506
|
+
static METHOD_GET = METHOD_GET;
|
|
507
|
+
static METHOD_HEAD = METHOD_HEAD;
|
|
508
|
+
static METHOD_OPTIONS = METHOD_OPTIONS;
|
|
509
|
+
static METHOD_PATCH = METHOD_PATCH;
|
|
510
|
+
static METHOD_POST = METHOD_POST;
|
|
511
|
+
static METHOD_PUT = METHOD_PUT;
|
|
512
|
+
};
|
|
458
513
|
|
|
459
514
|
/******************************************************************************/
|
|
@@ -331,7 +331,7 @@ const processLoggerEntries = function(response) {
|
|
|
331
331
|
parsed.type === 'main_frame' &&
|
|
332
332
|
parsed.aliased === false && (
|
|
333
333
|
parsed.filter === undefined ||
|
|
334
|
-
parsed.filter.modifier !== true
|
|
334
|
+
parsed.filter.modifier !== true && parsed.filter.source !== 'redirect'
|
|
335
335
|
)
|
|
336
336
|
) {
|
|
337
337
|
const separator = createLogSeparator(parsed, unboxed.url);
|