@browserless.io/browserless 2.20.1 → 2.21.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.
Files changed (137) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/bin/browserless.js +2 -1
  3. package/build/browserless.js +3 -2
  4. package/build/browsers/index.d.ts +3 -2
  5. package/build/browsers/index.js +3 -1
  6. package/build/router.js +7 -3
  7. package/build/routes/chrome/http/content.post.body.json +8 -8
  8. package/build/routes/chrome/http/pdf.post.body.json +8 -8
  9. package/build/routes/chrome/http/scrape.post.body.json +8 -8
  10. package/build/routes/chrome/http/screenshot.post.body.json +8 -8
  11. package/build/routes/chrome/tests/pdf.spec.js +24 -12
  12. package/build/routes/chromium/http/content.post.body.json +8 -8
  13. package/build/routes/chromium/http/pdf.post.body.json +8 -8
  14. package/build/routes/chromium/http/scrape.post.body.json +8 -8
  15. package/build/routes/chromium/http/screenshot.post.body.json +8 -8
  16. package/build/routes/chromium/tests/pdf.spec.js +24 -12
  17. package/build/shared/pdf.http.js +10 -5
  18. package/extensions/ublock/_locales/ar/messages.json +5 -1
  19. package/extensions/ublock/_locales/az/messages.json +4 -0
  20. package/extensions/ublock/_locales/be/messages.json +4 -0
  21. package/extensions/ublock/_locales/bg/messages.json +4 -0
  22. package/extensions/ublock/_locales/bn/messages.json +4 -0
  23. package/extensions/ublock/_locales/br_FR/messages.json +9 -5
  24. package/extensions/ublock/_locales/bs/messages.json +4 -0
  25. package/extensions/ublock/_locales/ca/messages.json +5 -1
  26. package/extensions/ublock/_locales/cs/messages.json +4 -0
  27. package/extensions/ublock/_locales/cv/messages.json +4 -0
  28. package/extensions/ublock/_locales/cy/messages.json +4 -0
  29. package/extensions/ublock/_locales/da/messages.json +4 -0
  30. package/extensions/ublock/_locales/de/messages.json +4 -0
  31. package/extensions/ublock/_locales/el/messages.json +8 -4
  32. package/extensions/ublock/_locales/en/messages.json +4 -0
  33. package/extensions/ublock/_locales/en_GB/messages.json +4 -0
  34. package/extensions/ublock/_locales/eo/messages.json +9 -5
  35. package/extensions/ublock/_locales/es/messages.json +4 -0
  36. package/extensions/ublock/_locales/et/messages.json +4 -0
  37. package/extensions/ublock/_locales/eu/messages.json +4 -0
  38. package/extensions/ublock/_locales/fa/messages.json +4 -0
  39. package/extensions/ublock/_locales/fi/messages.json +6 -2
  40. package/extensions/ublock/_locales/fil/messages.json +4 -0
  41. package/extensions/ublock/_locales/fr/messages.json +4 -0
  42. package/extensions/ublock/_locales/fy/messages.json +4 -0
  43. package/extensions/ublock/_locales/gl/messages.json +12 -8
  44. package/extensions/ublock/_locales/gu/messages.json +4 -0
  45. package/extensions/ublock/_locales/he/messages.json +4 -0
  46. package/extensions/ublock/_locales/hi/messages.json +4 -0
  47. package/extensions/ublock/_locales/hr/messages.json +4 -0
  48. package/extensions/ublock/_locales/hu/messages.json +68 -64
  49. package/extensions/ublock/_locales/hy/messages.json +4 -0
  50. package/extensions/ublock/_locales/id/messages.json +6 -2
  51. package/extensions/ublock/_locales/it/messages.json +4 -0
  52. package/extensions/ublock/_locales/ja/messages.json +4 -0
  53. package/extensions/ublock/_locales/ka/messages.json +4 -0
  54. package/extensions/ublock/_locales/kk/messages.json +4 -0
  55. package/extensions/ublock/_locales/kn/messages.json +4 -0
  56. package/extensions/ublock/_locales/ko/messages.json +4 -0
  57. package/extensions/ublock/_locales/lt/messages.json +4 -0
  58. package/extensions/ublock/_locales/lv/messages.json +4 -0
  59. package/extensions/ublock/_locales/mk/messages.json +4 -0
  60. package/extensions/ublock/_locales/ml/messages.json +4 -0
  61. package/extensions/ublock/_locales/mr/messages.json +4 -0
  62. package/extensions/ublock/_locales/ms/messages.json +4 -0
  63. package/extensions/ublock/_locales/nb/messages.json +4 -0
  64. package/extensions/ublock/_locales/nl/messages.json +4 -0
  65. package/extensions/ublock/_locales/no/messages.json +4 -0
  66. package/extensions/ublock/_locales/oc/messages.json +4 -0
  67. package/extensions/ublock/_locales/pa/messages.json +8 -4
  68. package/extensions/ublock/_locales/pl/messages.json +4 -0
  69. package/extensions/ublock/_locales/pt_BR/messages.json +4 -0
  70. package/extensions/ublock/_locales/pt_PT/messages.json +4 -0
  71. package/extensions/ublock/_locales/ro/messages.json +4 -0
  72. package/extensions/ublock/_locales/ru/messages.json +4 -0
  73. package/extensions/ublock/_locales/si/messages.json +4 -0
  74. package/extensions/ublock/_locales/sk/messages.json +4 -0
  75. package/extensions/ublock/_locales/sl/messages.json +4 -0
  76. package/extensions/ublock/_locales/so/messages.json +4 -0
  77. package/extensions/ublock/_locales/sq/messages.json +4 -0
  78. package/extensions/ublock/_locales/sr/messages.json +6 -2
  79. package/extensions/ublock/_locales/sv/messages.json +4 -0
  80. package/extensions/ublock/_locales/sw/messages.json +4 -0
  81. package/extensions/ublock/_locales/ta/messages.json +4 -0
  82. package/extensions/ublock/_locales/te/messages.json +4 -0
  83. package/extensions/ublock/_locales/th/messages.json +4 -0
  84. package/extensions/ublock/_locales/tr/messages.json +4 -0
  85. package/extensions/ublock/_locales/uk/messages.json +4 -0
  86. package/extensions/ublock/_locales/ur/messages.json +4 -0
  87. package/extensions/ublock/_locales/vi/messages.json +4 -0
  88. package/extensions/ublock/_locales/zh_CN/messages.json +4 -0
  89. package/extensions/ublock/_locales/zh_TW/messages.json +5 -1
  90. package/extensions/ublock/assets/assets.json +8 -6
  91. package/extensions/ublock/assets/resources/scriptlets.js +455 -301
  92. package/extensions/ublock/assets/thirdparties/easylist/easylist.txt +4441 -6643
  93. package/extensions/ublock/assets/thirdparties/easylist/easyprivacy.txt +401 -307
  94. package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/serverlist +34 -29
  95. package/extensions/ublock/assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat +682 -709
  96. package/extensions/ublock/assets/thirdparties/urlhaus-filter/urlhaus-filter-online.txt +2439 -1999
  97. package/extensions/ublock/assets/ublock/badlists.txt +7 -0
  98. package/extensions/ublock/assets/ublock/badware.min.txt +992 -552
  99. package/extensions/ublock/assets/ublock/filters.min.txt +1253 -864
  100. package/extensions/ublock/assets/ublock/privacy.min.txt +58 -31
  101. package/extensions/ublock/assets/ublock/quick-fixes.min.txt +118 -126
  102. package/extensions/ublock/assets/ublock/unbreak.min.txt +129 -109
  103. package/extensions/ublock/js/background.js +4 -3
  104. package/extensions/ublock/js/benchmarks.js +29 -29
  105. package/extensions/ublock/js/codemirror/ubo-static-filtering.js +1 -0
  106. package/extensions/ublock/js/contextmenu.js +20 -21
  107. package/extensions/ublock/js/devtools.js +137 -3
  108. package/extensions/ublock/js/filtering-context.js +98 -43
  109. package/extensions/ublock/js/logger-ui.js +1 -1
  110. package/extensions/ublock/js/messaging.js +57 -135
  111. package/extensions/ublock/js/pagestore.js +44 -31
  112. package/extensions/ublock/js/redirect-resources.js +14 -4
  113. package/extensions/ublock/js/scriptlet-filtering.js +4 -1
  114. package/extensions/ublock/js/static-filtering-parser.js +107 -37
  115. package/extensions/ublock/js/static-net-filtering.js +514 -250
  116. package/extensions/ublock/js/storage.js +2 -1
  117. package/extensions/ublock/js/traffic.js +8 -4
  118. package/extensions/ublock/js/vapi-background.js +1 -0
  119. package/extensions/ublock/js/vapi-common.js +1 -0
  120. package/extensions/ublock/logger-ui.html +2 -3
  121. package/extensions/ublock/manifest.json +2 -2
  122. package/extensions/ublock/support.html +1 -0
  123. package/extensions/ublock/web_accessible_resources/noop-vast2.xml +1 -0
  124. package/extensions/ublock/web_accessible_resources/noop-vast3.xml +1 -0
  125. package/extensions/ublock/web_accessible_resources/noop-vast4.xml +1 -0
  126. package/package.json +17 -17
  127. package/src/browserless.ts +3 -2
  128. package/src/browsers/index.ts +2 -0
  129. package/src/router.ts +10 -2
  130. package/src/routes/chrome/tests/pdf.spec.ts +24 -12
  131. package/src/routes/chromium/tests/pdf.spec.ts +24 -12
  132. package/src/shared/pdf.http.ts +10 -6
  133. package/static/docs/swagger.json +10 -10
  134. package/static/docs/swagger.min.json +9 -9
  135. package/static/function/client.js +9 -9
  136. package/static/function/index.html +9 -9
  137. /package/extensions/ublock/web_accessible_resources/{noop-vmap1.0.xml → noop-vmap1.xml} +0 -0
@@ -19,53 +19,49 @@
19
19
  Home: https://github.com/gorhill/uBlock
20
20
  */
21
21
 
22
- /* globals browser */
23
-
24
- 'use strict';
22
+ import * as s14e from './s14e-serializer.js';
23
+ import * as sfp from './static-filtering-parser.js';
25
24
 
26
- /******************************************************************************/
25
+ import {
26
+ domainFromHostname,
27
+ domainFromURI,
28
+ entityFromDomain,
29
+ hostnameFromURI,
30
+ isNetworkURI,
31
+ } from './uri-utils.js';
27
32
 
28
- import publicSuffixList from '../lib/publicsuffixlist/publicsuffixlist.js';
29
- import punycode from '../lib/punycode.js';
33
+ import {
34
+ permanentFirewall,
35
+ permanentSwitches,
36
+ permanentURLFiltering,
37
+ sessionFirewall,
38
+ sessionSwitches,
39
+ sessionURLFiltering,
40
+ } from './filtering-engines.js';
30
41
 
31
- import { filteringBehaviorChanged } from './broadcast.js';
32
42
  import cacheStorage from './cachestorage.js';
33
43
  import cosmeticFilteringEngine from './cosmetic-filtering.js';
44
+ import { denseBase64 } from './base64-custom.js';
45
+ import { filteringBehaviorChanged } from './broadcast.js';
34
46
  import htmlFilteringEngine from './html-filtering.js';
47
+ import { i18n$ } from './i18n.js';
48
+ import io from './assets.js';
35
49
  import logger from './logger.js';
36
50
  import lz4Codec from './lz4.js';
37
- import io from './assets.js';
51
+ import publicSuffixList from '../lib/publicsuffixlist/publicsuffixlist.js';
52
+ import punycode from '../lib/punycode.js';
53
+ import { redirectEngine } from './redirect-engine.js';
38
54
  import scriptletFilteringEngine from './scriptlet-filtering.js';
39
55
  import staticFilteringReverseLookup from './reverselookup.js';
40
56
  import staticNetFilteringEngine from './static-net-filtering.js';
41
- import µb from './background.js';
42
57
  import webRequest from './traffic.js';
43
- import { denseBase64 } from './base64-custom.js';
44
- import { dnrRulesetFromRawLists } from './static-dnr-filtering.js';
45
- import { i18n$ } from './i18n.js';
46
- import { redirectEngine } from './redirect-engine.js';
47
- import * as sfp from './static-filtering-parser.js';
48
- import * as s14e from './s14e-serializer.js';
49
-
50
- import {
51
- permanentFirewall,
52
- sessionFirewall,
53
- permanentSwitches,
54
- sessionSwitches,
55
- permanentURLFiltering,
56
- sessionURLFiltering,
57
- } from './filtering-engines.js';
58
-
59
- import {
60
- domainFromHostname,
61
- domainFromURI,
62
- entityFromDomain,
63
- hostnameFromURI,
64
- isNetworkURI,
65
- } from './uri-utils.js';
58
+ import µb from './background.js';
66
59
 
67
60
  /******************************************************************************/
68
61
 
62
+ const hasOwnProperty = (o, p) =>
63
+ Object.prototype.hasOwnProperty.call(o, p);
64
+
69
65
  // https://github.com/uBlockOrigin/uBlock-issues/issues/710
70
66
  // Listeners have a name and a "privileged" status.
71
67
  // The nameless default handler is always deemed "privileged".
@@ -291,9 +287,8 @@ const getHostnameDict = function(hostnameDetailsMap, out) {
291
287
  const cnMap = [];
292
288
 
293
289
  const createDictEntry = (domain, hostname, details) => {
294
- const cname = vAPI.net.canonicalNameFromHostname(hostname);
295
- if ( cname !== undefined ) {
296
- cnMap.push([ cname, hostname ]);
290
+ if ( details.cname ) {
291
+ cnMap.push([ details.cname, hostname ]);
297
292
  }
298
293
  hnDict[hostname] = { domain, counts: details.counts };
299
294
  };
@@ -807,7 +802,7 @@ const onMessage = function(request, sender, callback) {
807
802
  });
808
803
  break;
809
804
 
810
- case 'shouldRenderNoscriptTags':
805
+ case 'shouldRenderNoscriptTags': {
811
806
  if ( pageStore === null ) { break; }
812
807
  const fctxt = µb.filteringContext.fromTabId(sender.tabId);
813
808
  if ( pageStore.filterScripting(fctxt, undefined) ) {
@@ -818,7 +813,7 @@ const onMessage = function(request, sender, callback) {
818
813
  });
819
814
  }
820
815
  break;
821
-
816
+ }
822
817
  case 'retrieveGenericCosmeticSelectors':
823
818
  request.tabId = sender.tabId;
824
819
  request.frameId = sender.frameId;
@@ -1098,7 +1093,7 @@ const restoreUserData = async function(request) {
1098
1093
  // Discard unknown setting or setting with default value.
1099
1094
  for ( const key in hiddenSettings ) {
1100
1095
  if (
1101
- µb.hiddenSettingsDefault.hasOwnProperty(key) === false ||
1096
+ hasOwnProperty(µb.hiddenSettingsDefault, key) === false ||
1102
1097
  hiddenSettings[key] === µb.hiddenSettingsDefault[key]
1103
1098
  ) {
1104
1099
  delete hiddenSettings[key];
@@ -1128,7 +1123,7 @@ const restoreUserData = async function(request) {
1128
1123
  });
1129
1124
  µb.saveUserFilters(userData.userFilters);
1130
1125
  if ( Array.isArray(userData.selectedFilterLists) ) {
1131
- await µb.saveSelectedFilterLists(userData.selectedFilterLists);
1126
+ await µb.saveSelectedFilterLists(userData.selectedFilterLists);
1132
1127
  }
1133
1128
 
1134
1129
  vAPI.app.restart();
@@ -1150,7 +1145,7 @@ const resetUserData = async function() {
1150
1145
  // Filter lists
1151
1146
  const prepListEntries = function(entries) {
1152
1147
  for ( const k in entries ) {
1153
- if ( entries.hasOwnProperty(k) === false ) { continue; }
1148
+ if ( hasOwnProperty(entries, k) === false ) { continue; }
1154
1149
  const entry = entries[k];
1155
1150
  if ( typeof entry.supportURL === 'string' && entry.supportURL !== '' ) {
1156
1151
  entry.supportName = hostnameFromURI(entry.supportURL);
@@ -1338,7 +1333,7 @@ const getSupportData = async function() {
1338
1333
  let addedListset = {};
1339
1334
  let removedListset = {};
1340
1335
  for ( const listKey in lists ) {
1341
- if ( lists.hasOwnProperty(listKey) === false ) { continue; }
1336
+ if ( hasOwnProperty(lists, listKey) === false ) { continue; }
1342
1337
  const list = lists[listKey];
1343
1338
  if ( list.content !== 'filters' ) { continue; }
1344
1339
  const used = µb.selectedFilterLists.includes(listKey);
@@ -1755,7 +1750,7 @@ const onMessage = (request, sender, callback) => {
1755
1750
  // Sync
1756
1751
  let response;
1757
1752
  switch ( request.what ) {
1758
- case 'getInspectorArgs':
1753
+ case 'getInspectorArgs': {
1759
1754
  const bc = new globalThis.BroadcastChannel('contentInspectorChannel');
1760
1755
  bc.postMessage({
1761
1756
  what: 'contentInspectorChannel',
@@ -1768,6 +1763,7 @@ const onMessage = (request, sender, callback) => {
1768
1763
  ),
1769
1764
  };
1770
1765
  break;
1766
+ }
1771
1767
  default:
1772
1768
  return vAPI.messaging.UNHANDLED;
1773
1769
  }
@@ -1900,95 +1896,15 @@ const onMessage = function(request, sender, callback) {
1900
1896
  ),
1901
1897
  env: vAPI.webextFlavor.env,
1902
1898
  };
1903
- const t0 = Date.now();
1904
- dnrRulesetFromRawLists(listPromises, options).then(result => {
1905
- const { network } = result;
1906
- const replacer = (k, v) => {
1907
- if ( k.startsWith('__') ) { return; }
1908
- if ( Array.isArray(v) ) {
1909
- return v.sort();
1910
- }
1911
- if ( v instanceof Object ) {
1912
- const sorted = {};
1913
- for ( const kk of Object.keys(v).sort() ) {
1914
- sorted[kk] = v[kk];
1915
- }
1916
- return sorted;
1917
- }
1918
- return v;
1919
- };
1920
- const isUnsupported = rule =>
1921
- rule._error !== undefined;
1922
- const isRegex = rule =>
1923
- rule.condition !== undefined &&
1924
- rule.condition.regexFilter !== undefined;
1925
- const isRedirect = rule =>
1926
- rule.action !== undefined &&
1927
- rule.action.type === 'redirect' &&
1928
- rule.action.redirect.extensionPath !== undefined;
1929
- const isCsp = rule =>
1930
- rule.action !== undefined &&
1931
- rule.action.type === 'modifyHeaders';
1932
- const isRemoveparam = rule =>
1933
- rule.action !== undefined &&
1934
- rule.action.type === 'redirect' &&
1935
- rule.action.redirect.transform !== undefined;
1936
- const runtime = Date.now() - t0;
1937
- const { ruleset } = network;
1938
- const good = ruleset.filter(rule =>
1939
- isUnsupported(rule) === false &&
1940
- isRegex(rule) === false &&
1941
- isRedirect(rule) === false &&
1942
- isCsp(rule) === false &&
1943
- isRemoveparam(rule) === false
1944
- );
1945
- const unsupported = ruleset.filter(rule =>
1946
- isUnsupported(rule)
1947
- );
1948
- const regexes = ruleset.filter(rule =>
1949
- isUnsupported(rule) === false &&
1950
- isRegex(rule) &&
1951
- isRedirect(rule) === false &&
1952
- isCsp(rule) === false &&
1953
- isRemoveparam(rule) === false
1954
- );
1955
- const redirects = ruleset.filter(rule =>
1956
- isUnsupported(rule) === false &&
1957
- isRedirect(rule)
1958
- );
1959
- const headers = ruleset.filter(rule =>
1960
- isUnsupported(rule) === false &&
1961
- isCsp(rule)
1962
- );
1963
- const removeparams = ruleset.filter(rule =>
1964
- isUnsupported(rule) === false &&
1965
- isRemoveparam(rule)
1966
- );
1967
- const out = [
1968
- `dnrRulesetFromRawLists(${JSON.stringify(listNames, null, 2)})`,
1969
- `Run time: ${runtime} ms`,
1970
- `Filters count: ${network.filterCount}`,
1971
- `Accepted filter count: ${network.acceptedFilterCount}`,
1972
- `Rejected filter count: ${network.rejectedFilterCount}`,
1973
- `Un-DNR-able filter count: ${unsupported.length}`,
1974
- `Resulting DNR rule count: ${ruleset.length}`,
1975
- ];
1976
- out.push(`+ Good filters (${good.length}): ${JSON.stringify(good, replacer, 2)}`);
1977
- out.push(`+ Regex-based filters (${regexes.length}): ${JSON.stringify(regexes, replacer, 2)}`);
1978
- out.push(`+ 'redirect=' filters (${redirects.length}): ${JSON.stringify(redirects, replacer, 2)}`);
1979
- out.push(`+ 'csp=' filters (${headers.length}): ${JSON.stringify(headers, replacer, 2)}`);
1980
- out.push(`+ 'removeparam=' filters (${removeparams.length}): ${JSON.stringify(removeparams, replacer, 2)}`);
1981
- out.push(`+ Unsupported filters (${unsupported.length}): ${JSON.stringify(unsupported, replacer, 2)}`);
1982
- out.push(`+ generichide exclusions (${network.generichideExclusions.length}): ${JSON.stringify(network.generichideExclusions, replacer, 2)}`);
1983
- if ( result.specificCosmetic ) {
1984
- out.push(`+ Cosmetic filters: ${result.specificCosmetic.size}`);
1985
- for ( const details of result.specificCosmetic ) {
1986
- out.push(` ${JSON.stringify(details)}`);
1987
- }
1988
- } else {
1989
- out.push(' Cosmetic filters: 0');
1990
- }
1991
- callback(out.join('\n'));
1899
+ import('./static-dnr-filtering.js').then(module => {
1900
+ const t0 = Date.now();
1901
+ module.dnrRulesetFromRawLists(listPromises, options).then(dnrdata => {
1902
+ dnrdata.listNames = listNames;
1903
+ dnrdata.runtime = Date.now() - t0;
1904
+ callback(s14e.serialize(dnrdata));
1905
+ })
1906
+ }).catch(reason => {
1907
+ callback(reason);
1992
1908
  });
1993
1909
  return;
1994
1910
  }
@@ -2004,6 +1920,12 @@ const onMessage = function(request, sender, callback) {
2004
1920
  response = staticNetFilteringEngine.dump();
2005
1921
  break;
2006
1922
 
1923
+ case 'snfeQuery':
1924
+ response = staticNetFilteringEngine.test(
1925
+ Object.assign({ redirectEngine }, request.query)
1926
+ );
1927
+ break;
1928
+
2007
1929
  case 'cfeDump':
2008
1930
  response = cosmeticFilteringEngine.dump();
2009
1931
  break;
@@ -2181,7 +2103,7 @@ const onMessage = function(request, sender, callback) {
2181
2103
  }
2182
2104
  break;
2183
2105
 
2184
- case 'subscribeTo':
2106
+ case 'subscribeTo': {
2185
2107
  // https://github.com/uBlockOrigin/uBlock-issues/issues/1797
2186
2108
  if ( /^(file|https?):\/\//.test(request.location) === false ) { break; }
2187
2109
  const url = encodeURIComponent(request.location);
@@ -2194,8 +2116,8 @@ const onMessage = function(request, sender, callback) {
2194
2116
  select: true,
2195
2117
  });
2196
2118
  break;
2197
-
2198
- case 'updateLists':
2119
+ }
2120
+ case 'updateLists': {
2199
2121
  const listkeys = request.listkeys.split(',').filter(s => s !== '');
2200
2122
  if ( listkeys.length === 0 ) { return; }
2201
2123
  if ( listkeys.includes('all') ) {
@@ -2211,7 +2133,7 @@ const onMessage = function(request, sender, callback) {
2211
2133
  });
2212
2134
  µb.scheduleAssetUpdater({ now: true, fetchDelay: 100, auto: request.auto });
2213
2135
  break;
2214
-
2136
+ }
2215
2137
  default:
2216
2138
  return vAPI.messaging.UNHANDLED;
2217
2139
  }
@@ -53,6 +53,9 @@ To create a log of net requests
53
53
  /******************************************************************************/
54
54
 
55
55
  const NetFilteringResultCache = class {
56
+ shelfLife = 15000;
57
+ extensionOriginURL = vAPI.getURL('/');
58
+
56
59
  constructor() {
57
60
  this.pruneTimer = vAPI.defer.create(( ) => {
58
61
  this.prune();
@@ -172,9 +175,6 @@ const NetFilteringResultCache = class {
172
175
  }
173
176
  };
174
177
 
175
- NetFilteringResultCache.prototype.shelfLife = 15000;
176
- NetFilteringResultCache.prototype.extensionOriginURL = vAPI.getURL('/');
177
-
178
178
  /******************************************************************************/
179
179
 
180
180
  // Frame stores are used solely to associate a URL with a frame id.
@@ -274,18 +274,16 @@ const FrameStore = class {
274
274
  }
275
275
 
276
276
  static factory(frameURL, parentId = -1) {
277
- const entry = FrameStore.junkyard.pop();
278
- if ( entry === undefined ) {
279
- return new FrameStore(frameURL, parentId);
277
+ const FS = FrameStore;
278
+ if ( FS.junkyard.length !== 0 ) {
279
+ return FS.junkyard.pop().init(frameURL, parentId);
280
280
  }
281
- return entry.init(frameURL, parentId);
281
+ return new FS(frameURL, parentId);
282
282
  }
283
+ static junkyard = [];
284
+ static junkyardMax = 50;
283
285
  };
284
286
 
285
- // To mitigate memory churning
286
- FrameStore.junkyard = [];
287
- FrameStore.junkyardMax = 50;
288
-
289
287
  /******************************************************************************/
290
288
 
291
289
  const CountDetails = class {
@@ -312,19 +310,26 @@ const HostnameDetails = class {
312
310
  }
313
311
  init(hostname) {
314
312
  this.hostname = hostname;
313
+ this.cname = vAPI.net.canonicalNameFromHostname(hostname);
315
314
  this.counts.reset();
315
+ return this;
316
316
  }
317
317
  dispose() {
318
- this.hostname = '';
319
- if ( HostnameDetails.junkyard.length < HostnameDetails.junkyardMax ) {
320
- HostnameDetails.junkyard.push(this);
318
+ const HD = HostnameDetails;
319
+ if ( HD.junkyard.length >= HD.junkyardMax ) { return; }
320
+ HD.junkyard.push(this);
321
+ }
322
+ static factory(hostname) {
323
+ const HD = HostnameDetails;
324
+ if ( HD.junkyard.length !== 0 ) {
325
+ return HD.junkyard.pop().init(hostname);
321
326
  }
327
+ return new HD(hostname);
322
328
  }
329
+ static junkyard = [];
330
+ static junkyardMax = 100;
323
331
  };
324
332
 
325
- HostnameDetails.junkyard = [];
326
- HostnameDetails.junkyardMax = 100;
327
-
328
333
  const HostnameDetailsMap = class extends Map {
329
334
  reset() {
330
335
  this.clear();
@@ -622,7 +627,7 @@ const PageStore = class {
622
627
  ) {
623
628
  this.hostnameDetailsMap.set(
624
629
  this.tabHostname,
625
- new HostnameDetails(this.tabHostname)
630
+ HostnameDetails.factory(this.tabHostname)
626
631
  );
627
632
  }
628
633
  return this.hostnameDetailsMap;
@@ -700,7 +705,7 @@ const PageStore = class {
700
705
  const hostname = journal[i+0];
701
706
  let hnDetails = this.hostnameDetailsMap.get(hostname);
702
707
  if ( hnDetails === undefined ) {
703
- hnDetails = new HostnameDetails(hostname);
708
+ hnDetails = HostnameDetails.factory(hostname);
704
709
  this.hostnameDetailsMap.set(hostname, hnDetails);
705
710
  this.contentLastModified = now;
706
711
  }
@@ -932,19 +937,14 @@ const PageStore = class {
932
937
  }
933
938
 
934
939
  redirectNonBlockedRequest(fctxt) {
935
- const transformDirectives = staticNetFilteringEngine.transformRequest(fctxt);
936
- const pruneDirectives = fctxt.redirectURL === undefined &&
937
- staticNetFilteringEngine.hasQuery(fctxt) &&
938
- staticNetFilteringEngine.filterQuery(fctxt) ||
939
- undefined;
940
- if ( transformDirectives === undefined && pruneDirectives === undefined ) { return; }
941
- if ( logger.enabled !== true ) { return; }
942
- if ( transformDirectives !== undefined ) {
943
- fctxt.pushFilters(transformDirectives.map(a => a.logData()));
944
- }
945
- if ( pruneDirectives !== undefined ) {
946
- fctxt.pushFilters(pruneDirectives.map(a => a.logData()));
940
+ const directives = [];
941
+ staticNetFilteringEngine.transformRequest(fctxt, directives);
942
+ if ( staticNetFilteringEngine.hasQuery(fctxt) ) {
943
+ staticNetFilteringEngine.filterQuery(fctxt, directives);
947
944
  }
945
+ if ( directives.length === 0 ) { return; }
946
+ if ( logger.enabled !== true ) { return; }
947
+ fctxt.pushFilters(directives.map(a => a.logData()));
948
948
  if ( fctxt.redirectURL === undefined ) { return; }
949
949
  fctxt.pushFilter({
950
950
  source: 'redirect',
@@ -952,6 +952,19 @@ const PageStore = class {
952
952
  });
953
953
  }
954
954
 
955
+ skipMainDocument(fctxt) {
956
+ const directives = staticNetFilteringEngine.urlSkip(fctxt);
957
+ if ( directives === undefined ) { return; }
958
+ if ( logger.enabled !== true ) { return; }
959
+ fctxt.pushFilters(directives.map(a => a.logData()));
960
+ if ( fctxt.redirectURL !== undefined ) {
961
+ fctxt.pushFilter({
962
+ source: 'redirect',
963
+ raw: fctxt.redirectURL
964
+ });
965
+ }
966
+ }
967
+
955
968
  filterCSPReport(fctxt) {
956
969
  if (
957
970
  sessionSwitches.evaluateZ(
@@ -19,8 +19,6 @@
19
19
  Home: https://github.com/gorhill/uBlock
20
20
  */
21
21
 
22
- 'use strict';
23
-
24
22
  /******************************************************************************/
25
23
 
26
24
  // The resources referenced below are found in ./web_accessible_resources/
@@ -159,8 +157,20 @@ export default new Map([
159
157
  alias: 'nooptext',
160
158
  data: 'text',
161
159
  } ],
162
- [ 'noop-vmap1.0.xml', {
163
- alias: 'noopvmap-1.0',
160
+ [ 'noop-vast2.xml', {
161
+ alias: 'noopvast-2.0',
162
+ data: 'text',
163
+ } ],
164
+ [ 'noop-vast3.xml', {
165
+ alias: 'noopvast-3.0',
166
+ data: 'text',
167
+ } ],
168
+ [ 'noop-vast4.xml', {
169
+ alias: 'noopvast-4.0',
170
+ data: 'text',
171
+ } ],
172
+ [ 'noop-vmap1.xml', {
173
+ alias: [ 'noop-vmap1.0.xml', 'noopvmap-1.0' ],
164
174
  data: 'text',
165
175
  } ],
166
176
  [ 'outbrain-widget.js', {
@@ -61,6 +61,7 @@ const contentScriptRegisterer = new (class {
61
61
  runAt: 'document_start',
62
62
  }).then(handle => {
63
63
  this.hostnameToDetails.set(hostname, { handle, code });
64
+ return handle;
64
65
  }).catch(( ) => {
65
66
  this.hostnameToDetails.delete(hostname);
66
67
  });
@@ -94,7 +95,9 @@ const contentScriptRegisterer = new (class {
94
95
  }
95
96
  unregisterHandle(handle) {
96
97
  if ( handle instanceof Promise ) {
97
- handle.then(handle => { handle.unregister(); });
98
+ handle.then(handle => {
99
+ if ( handle ) { handle.unregister(); }
100
+ });
98
101
  } else {
99
102
  handle.unregister();
100
103
  }