@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.
Files changed (246) hide show
  1. package/LICENSE +2 -0
  2. package/README.md +11 -11
  3. package/bin/browserless.js +169 -11
  4. package/bin/scaffold/README.md +415 -0
  5. package/bin/scaffold/package.json +21 -0
  6. package/bin/scaffold/src/hello-world.http.ts +27 -0
  7. package/bin/scaffold/tsconfig.json +4 -0
  8. package/build/browserless.js +18 -15
  9. package/build/browsers/index.d.ts +2 -18
  10. package/build/browsers/index.js +43 -14
  11. package/build/file-system.d.ts +5 -0
  12. package/build/file-system.js +20 -5
  13. package/build/file-system.spec.d.ts +1 -0
  14. package/build/file-system.spec.js +44 -0
  15. package/build/http.d.ts +3 -3
  16. package/build/http.js +3 -3
  17. package/build/router.js +2 -4
  18. package/build/routes/chromium/http/content-post.body.json +8 -8
  19. package/build/routes/chromium/http/content-post.d.ts +15 -3
  20. package/build/routes/chromium/http/content-post.js +14 -15
  21. package/build/routes/chromium/http/download-post.d.ts +16 -3
  22. package/build/routes/chromium/http/download-post.js +17 -22
  23. package/build/routes/chromium/http/function-post.d.ts +16 -3
  24. package/build/routes/chromium/http/function-post.js +17 -22
  25. package/build/routes/chromium/http/pdf-post.body.json +8 -8
  26. package/build/routes/chromium/http/pdf-post.d.ts +15 -3
  27. package/build/routes/chromium/http/pdf-post.js +19 -15
  28. package/build/routes/chromium/http/performance.d.ts +15 -3
  29. package/build/routes/chromium/http/performance.js +15 -23
  30. package/build/routes/chromium/http/scrape-post.body.json +8 -8
  31. package/build/routes/chromium/http/scrape-post.d.ts +15 -3
  32. package/build/routes/chromium/http/scrape-post.js +15 -16
  33. package/build/routes/chromium/http/screenshot-post.body.json +8 -8
  34. package/build/routes/chromium/http/screenshot-post.d.ts +15 -3
  35. package/build/routes/chromium/http/screenshot-post.js +18 -15
  36. package/build/routes/chromium/tests/websocket.spec.js +20 -1
  37. package/build/routes/chromium/utils/function/handler.js +2 -2
  38. package/build/routes/chromium/ws/browser.d.ts +13 -3
  39. package/build/routes/chromium/ws/browser.js +10 -11
  40. package/build/routes/chromium/ws/cdp-chromium.d.ts +13 -3
  41. package/build/routes/chromium/ws/cdp-chromium.js +10 -11
  42. package/build/routes/chromium/ws/page.d.ts +13 -3
  43. package/build/routes/chromium/ws/page.js +10 -11
  44. package/build/routes/chromium/ws/playwright-chromium.d.ts +13 -3
  45. package/build/routes/chromium/ws/playwright-chromium.js +11 -12
  46. package/build/routes/firefox/ws/playwright-firefox.d.ts +13 -3
  47. package/build/routes/firefox/ws/playwright-firefox.js +11 -12
  48. package/build/routes/management/http/config-get.d.ts +15 -3
  49. package/build/routes/management/http/config-get.js +15 -20
  50. package/build/routes/management/http/metrics-get.d.ts +15 -3
  51. package/build/routes/management/http/metrics-get.js +16 -21
  52. package/build/routes/management/http/metrics-total-get.d.ts +15 -3
  53. package/build/routes/management/http/metrics-total-get.js +16 -21
  54. package/build/routes/management/http/sessions-get.d.ts +15 -3
  55. package/build/routes/management/http/sessions-get.js +16 -20
  56. package/build/routes/management/http/static-get.d.ts +15 -3
  57. package/build/routes/management/http/static-get.js +15 -20
  58. package/build/routes/webkit/ws/playwright-webkit.d.ts +13 -3
  59. package/build/routes/webkit/ws/playwright-webkit.js +11 -12
  60. package/build/server.js +0 -1
  61. package/build/types.d.ts +48 -38
  62. package/build/types.js +135 -0
  63. package/extensions/ublock/1p-filters.html +0 -1
  64. package/extensions/ublock/3p-filters.html +0 -2
  65. package/extensions/ublock/_locales/bg/messages.json +6 -6
  66. package/extensions/ublock/_locales/br_FR/messages.json +14 -14
  67. package/extensions/ublock/_locales/bs/messages.json +8 -8
  68. package/extensions/ublock/_locales/ca/messages.json +1 -1
  69. package/extensions/ublock/_locales/da/messages.json +5 -5
  70. package/extensions/ublock/_locales/fa/messages.json +1 -1
  71. package/extensions/ublock/_locales/fi/messages.json +6 -6
  72. package/extensions/ublock/_locales/hr/messages.json +4 -4
  73. package/extensions/ublock/_locales/nb/messages.json +1 -1
  74. package/extensions/ublock/_locales/no/messages.json +1 -1
  75. package/extensions/ublock/_locales/ro/messages.json +2 -2
  76. package/extensions/ublock/_locales/ru/messages.json +1 -1
  77. package/extensions/ublock/_locales/sk/messages.json +1 -1
  78. package/extensions/ublock/_locales/sv/messages.json +2 -2
  79. package/extensions/ublock/_locales/te/messages.json +17 -17
  80. package/extensions/ublock/_locales/vi/messages.json +12 -12
  81. package/extensions/ublock/_locales/zh_TW/messages.json +13 -13
  82. package/extensions/ublock/assets/assets.json +3 -3
  83. package/extensions/ublock/assets/resources/scriptlets.js +218 -97
  84. package/extensions/ublock/assets/thirdparties/easylist/easylist.txt +3010 -2056
  85. package/extensions/ublock/assets/thirdparties/easylist/easyprivacy.txt +624 -433
  86. package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/serverlist +93 -24
  87. package/extensions/ublock/assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat +7 -15
  88. package/extensions/ublock/assets/thirdparties/urlhaus-filter/urlhaus-filter-online.txt +795 -777
  89. package/extensions/ublock/assets/ublock/badware.min.txt +138 -72
  90. package/extensions/ublock/assets/ublock/filters.min.txt +1929 -2735
  91. package/extensions/ublock/assets/ublock/privacy.min.txt +57 -26
  92. package/extensions/ublock/assets/ublock/quick-fixes.min.txt +125 -74
  93. package/extensions/ublock/assets/ublock/unbreak.min.txt +46 -53
  94. package/extensions/ublock/css/codemirror.css +8 -7
  95. package/extensions/ublock/css/dom-inspector.css +40 -0
  96. package/extensions/ublock/css/logger-ui-inspector.css +7 -1
  97. package/extensions/ublock/css/logger-ui.css +12 -5
  98. package/extensions/ublock/css/popup-fenix.css +1 -1
  99. package/extensions/ublock/devtools.html +1 -0
  100. package/extensions/ublock/js/1p-filters.js +4 -3
  101. package/extensions/ublock/js/3p-filters.js +25 -31
  102. package/extensions/ublock/js/about.js +1 -1
  103. package/extensions/ublock/js/advanced-settings.js +1 -1
  104. package/extensions/ublock/js/asset-viewer.js +1 -1
  105. package/extensions/ublock/js/assets.js +74 -44
  106. package/extensions/ublock/js/background.js +9 -3
  107. package/extensions/ublock/js/base64-custom.js +1 -1
  108. package/extensions/ublock/js/benchmarks.js +1 -1
  109. package/extensions/ublock/js/biditrie.js +1 -1
  110. package/extensions/ublock/js/broadcast.js +75 -0
  111. package/extensions/ublock/js/cachestorage.js +68 -45
  112. package/extensions/ublock/js/click2load.js +1 -1
  113. package/extensions/ublock/js/cloud-ui.js +1 -1
  114. package/extensions/ublock/js/code-viewer.js +1 -1
  115. package/extensions/ublock/js/codemirror/search-thread.js +1 -1
  116. package/extensions/ublock/js/codemirror/search.js +1 -1
  117. package/extensions/ublock/js/codemirror/ubo-dynamic-filtering.js +1 -1
  118. package/extensions/ublock/js/codemirror/ubo-static-filtering.js +98 -24
  119. package/extensions/ublock/js/commands.js +1 -1
  120. package/extensions/ublock/js/console.js +1 -1
  121. package/extensions/ublock/js/contentscript-extra.js +1 -1
  122. package/extensions/ublock/js/contentscript.js +1 -3
  123. package/extensions/ublock/js/contextmenu.js +1 -1
  124. package/extensions/ublock/js/cosmetic-filtering.js +4 -4
  125. package/extensions/ublock/js/dashboard-common.js +1 -1
  126. package/extensions/ublock/js/dashboard.js +1 -1
  127. package/extensions/ublock/js/devtools.js +23 -15
  128. package/extensions/ublock/js/diff-updater.js +3 -3
  129. package/extensions/ublock/js/document-blocked.js +1 -1
  130. package/extensions/ublock/js/dom-inspector.js +68 -0
  131. package/extensions/ublock/js/dom.js +1 -1
  132. package/extensions/ublock/js/dyna-rules.js +1 -1
  133. package/extensions/ublock/js/dynamic-net-filtering.js +1 -1
  134. package/extensions/ublock/js/epicker-ui.js +35 -59
  135. package/extensions/ublock/js/fa-icons.js +1 -1
  136. package/extensions/ublock/js/filtering-context.js +1 -1
  137. package/extensions/ublock/js/filtering-engines.js +1 -1
  138. package/extensions/ublock/js/hnswitches.js +1 -1
  139. package/extensions/ublock/js/hntrie.js +1 -1
  140. package/extensions/ublock/js/html-filtering.js +1 -1
  141. package/extensions/ublock/js/httpheader-filtering.js +1 -1
  142. package/extensions/ublock/js/i18n.js +1 -1
  143. package/extensions/ublock/js/is-webrtc-supported.js +1 -1
  144. package/extensions/ublock/js/logger-ui-inspector.js +203 -145
  145. package/extensions/ublock/js/logger-ui.js +21 -5
  146. package/extensions/ublock/js/logger.js +6 -2
  147. package/extensions/ublock/js/lz4.js +2 -2
  148. package/extensions/ublock/js/messaging.js +266 -166
  149. package/extensions/ublock/js/mrucache.js +58 -0
  150. package/extensions/ublock/js/pagestore.js +1 -1
  151. package/extensions/ublock/js/popup-fenix.js +2 -1
  152. package/extensions/ublock/js/redirect-engine.js +1 -1
  153. package/extensions/ublock/js/redirect-resources.js +1 -12
  154. package/extensions/ublock/js/reverselookup-worker.js +1 -1
  155. package/extensions/ublock/js/reverselookup.js +1 -1
  156. package/extensions/ublock/js/scriptlet-filtering-core.js +300 -0
  157. package/extensions/ublock/js/scriptlet-filtering.js +122 -350
  158. package/extensions/ublock/js/scriptlets/cosmetic-logger.js +36 -47
  159. package/extensions/ublock/js/scriptlets/cosmetic-off.js +1 -1
  160. package/extensions/ublock/js/scriptlets/cosmetic-on.js +1 -1
  161. package/extensions/ublock/js/scriptlets/cosmetic-report.js +1 -1
  162. package/extensions/ublock/js/scriptlets/dom-inspector.js +341 -323
  163. package/extensions/ublock/js/scriptlets/dom-survey-elements.js +1 -1
  164. package/extensions/ublock/js/scriptlets/dom-survey-scripts.js +1 -1
  165. package/extensions/ublock/js/scriptlets/epicker.js +80 -89
  166. package/extensions/ublock/js/scriptlets/load-3p-css.js +1 -1
  167. package/extensions/ublock/js/scriptlets/load-large-media-all.js +1 -1
  168. package/extensions/ublock/js/scriptlets/load-large-media-interactive.js +1 -1
  169. package/extensions/ublock/js/scriptlets/noscript-spoof.js +1 -1
  170. package/extensions/ublock/js/scriptlets/should-inject-contentscript.js +1 -1
  171. package/extensions/ublock/js/scriptlets/subscriber.js +1 -1
  172. package/extensions/ublock/js/scriptlets/updater.js +20 -3
  173. package/extensions/ublock/js/settings.js +1 -1
  174. package/extensions/ublock/js/start.js +19 -20
  175. package/extensions/ublock/js/static-dnr-filtering.js +1 -1
  176. package/extensions/ublock/js/static-ext-filtering-db.js +1 -1
  177. package/extensions/ublock/js/static-ext-filtering.js +1 -1
  178. package/extensions/ublock/js/static-filtering-io.js +1 -1
  179. package/extensions/ublock/js/static-filtering-parser.js +5 -3
  180. package/extensions/ublock/js/static-net-filtering.js +57 -37
  181. package/extensions/ublock/js/storage.js +49 -29
  182. package/extensions/ublock/js/support.js +4 -4
  183. package/extensions/ublock/js/tab.js +1 -1
  184. package/extensions/ublock/js/tasks.js +1 -1
  185. package/extensions/ublock/js/text-encode.js +1 -1
  186. package/extensions/ublock/js/text-utils.js +1 -1
  187. package/extensions/ublock/js/theme.js +1 -1
  188. package/extensions/ublock/js/traffic.js +2 -1
  189. package/extensions/ublock/js/ublock.js +15 -11
  190. package/extensions/ublock/js/uri-utils.js +1 -1
  191. package/extensions/ublock/js/url-net-filtering.js +1 -1
  192. package/extensions/ublock/js/utils.js +1 -73
  193. package/extensions/ublock/js/vapi-background-ext.js +1 -1
  194. package/extensions/ublock/js/vapi-background.js +92 -83
  195. package/extensions/ublock/js/vapi-client.js +4 -33
  196. package/extensions/ublock/js/vapi-common.js +16 -30
  197. package/extensions/ublock/js/vapi.js +1 -1
  198. package/extensions/ublock/js/wasm/biditrie.wat +1 -1
  199. package/extensions/ublock/js/wasm/hntrie.wat +1 -1
  200. package/extensions/ublock/js/webext.js +1 -1
  201. package/extensions/ublock/js/whitelist.js +1 -1
  202. package/extensions/ublock/logger-ui.html +2 -2
  203. package/extensions/ublock/manifest.json +1 -1
  204. package/extensions/ublock/support.html +0 -1
  205. package/extensions/ublock/web_accessible_resources/dom-inspector.html +25 -0
  206. package/extensions/ublock/web_accessible_resources/epicker-ui.html +0 -1
  207. package/extensions/ublock/web_accessible_resources/googletagservices_gpt.js +1 -0
  208. package/package.json +7 -19
  209. package/scripts/build-open-api.js +7 -4
  210. package/src/browserless.ts +42 -18
  211. package/src/browsers/index.ts +48 -20
  212. package/src/file-system.spec.ts +58 -0
  213. package/src/file-system.ts +36 -8
  214. package/src/http.ts +3 -3
  215. package/src/router.ts +2 -6
  216. package/src/routes/chromium/http/content-post.ts +13 -16
  217. package/src/routes/chromium/http/download-post.ts +16 -27
  218. package/src/routes/chromium/http/function-post.ts +16 -25
  219. package/src/routes/chromium/http/pdf-post.ts +19 -15
  220. package/src/routes/chromium/http/performance.ts +14 -26
  221. package/src/routes/chromium/http/scrape-post.ts +14 -16
  222. package/src/routes/chromium/http/screenshot-post.ts +18 -15
  223. package/src/routes/chromium/tests/websocket.spec.ts +28 -1
  224. package/src/routes/chromium/utils/function/handler.ts +2 -1
  225. package/src/routes/chromium/ws/browser.ts +10 -12
  226. package/src/routes/chromium/ws/cdp-chromium.ts +10 -12
  227. package/src/routes/chromium/ws/page.ts +10 -12
  228. package/src/routes/chromium/ws/playwright-chromium.ts +10 -12
  229. package/src/routes/firefox/ws/playwright-firefox.ts +10 -12
  230. package/src/routes/management/http/config-get.ts +14 -23
  231. package/src/routes/management/http/metrics-get.ts +15 -24
  232. package/src/routes/management/http/metrics-total-get.ts +15 -26
  233. package/src/routes/management/http/sessions-get.ts +15 -23
  234. package/src/routes/management/http/static-get.ts +14 -22
  235. package/src/routes/webkit/ws/playwright-webkit.ts +10 -12
  236. package/src/server.ts +0 -1
  237. package/src/types.ts +59 -45
  238. package/static/docs/browserless-logo-inline.svg +1 -0
  239. package/static/docs/index.html +27 -0
  240. package/static/docs/swagger.json +33 -33
  241. package/static/function/client.js +626 -78
  242. package/extensions/ublock/js/vapi-client-extra.js +0 -312
  243. package/extensions/ublock/web_accessible_resources/addthis_widget.js +0 -39
  244. package/extensions/ublock/web_accessible_resources/ligatus_angular-tag.js +0 -29
  245. package/extensions/ublock/web_accessible_resources/monkeybroker.js +0 -43
  246. package/extensions/ublock/web_accessible_resources/mxpnl_mixpanel.js +0 -51
@@ -1,6 +1,6 @@
1
1
  /*******************************************************************************
2
2
 
3
- uBlock Origin - a browser extension to block requests.
3
+ uBlock Origin - a comprehensive, efficient content blocker
4
4
  Copyright (C) 2015-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 browser extension to block requests.
3
+ uBlock Origin - a comprehensive, efficient content blocker
4
4
  Copyright (C) 2015-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 browser extension to block requests.
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
@@ -30,19 +30,13 @@
30
30
 
31
31
  /******************************************************************************/
32
32
 
33
- if ( typeof vAPI !== 'object' || vAPI === null ) {
34
- return;
35
- }
36
-
37
- /******************************************************************************/
33
+ if ( typeof vAPI !== 'object' ) { return; }
34
+ if ( typeof vAPI === null ) { return; }
38
35
 
39
- const epickerId = vAPI.randomToken();
40
- let epickerConnectionId;
36
+ if ( vAPI.pickerFrame ) { return; }
37
+ vAPI.pickerFrame = true;
41
38
 
42
- let pickerRoot = document.querySelector(`[${vAPI.sessionId}]`);
43
- if ( pickerRoot !== null ) { return; }
44
-
45
- let pickerBootArgs;
39
+ const pickerUniqueId = vAPI.randomToken();
46
40
 
47
41
  const reCosmeticAnchor = /^#(\$|\?|\$\?)?#/;
48
42
 
@@ -129,7 +123,7 @@ const highlightElements = function(elems, force) {
129
123
  const islands = [];
130
124
 
131
125
  for ( const elem of elems ) {
132
- if ( elem === pickerRoot ) { continue; }
126
+ if ( elem === pickerFrame ) { continue; }
133
127
  targetElements.push(elem);
134
128
  const rect = getElementBoundingClientRect(elem);
135
129
  // Ignore offscreen areas
@@ -144,7 +138,7 @@ const highlightElements = function(elems, force) {
144
138
  );
145
139
  }
146
140
 
147
- vAPI.MessagingConnection.sendTo(epickerConnectionId, {
141
+ pickerFramePort.postMessage({
148
142
  what: 'svgPaths',
149
143
  ocean: `M0 0h${ow}v${oh}h-${ow}z`,
150
144
  islands: islands.join(''),
@@ -555,10 +549,10 @@ const filtersFrom = function(x, y) {
555
549
  // https://www.reddit.com/r/uBlockOrigin/comments/qmjk36/
556
550
  // Extract network candidates first.
557
551
  if ( typeof x === 'number' ) {
558
- const magicAttr = `${vAPI.sessionId}-clickblind`;
559
- pickerRoot.setAttribute(magicAttr, '');
552
+ const magicAttr = `${pickerUniqueId}-clickblind`;
553
+ pickerFrame.setAttribute(magicAttr, '');
560
554
  const elems = document.elementsFromPoint(x, y);
561
- pickerRoot.removeAttribute(magicAttr);
555
+ pickerFrame.removeAttribute(magicAttr);
562
556
  for ( const elem of elems ) {
563
557
  netFilterFromElement(elem);
564
558
  }
@@ -738,7 +732,7 @@ const filterToDOMInterface = (( ) => {
738
732
  }
739
733
  const out = [];
740
734
  for ( const elem of elems ) {
741
- if ( elem === pickerRoot ) { continue; }
735
+ if ( elem === pickerFrame ) { continue; }
742
736
  out.push({ elem, raw, style: vAPI.hideStyle });
743
737
  }
744
738
  return out;
@@ -816,7 +810,7 @@ const filterToDOMInterface = (( ) => {
816
810
  if ( Array.isArray(lastResultset) === false ) { return; }
817
811
  const rootElem = document.documentElement;
818
812
  for ( const { elem, style } of lastResultset ) {
819
- if ( elem === pickerRoot ) { continue; }
813
+ if ( elem === pickerFrame ) { continue; }
820
814
  if ( style === undefined ) { continue; }
821
815
  if ( elem === rootElem && style === vAPI.hideStyle ) { continue; }
822
816
  let styleToken = vAPI.epickerStyleProxies.get(style);
@@ -900,7 +894,7 @@ const onOptimizeCandidates = function(details) {
900
894
  if ( r !== 0 ) { return r; }
901
895
  return a.selector.length - b.selector.length;
902
896
  });
903
- vAPI.MessagingConnection.sendTo(epickerConnectionId, {
897
+ pickerFramePort.postMessage({
904
898
  what: 'candidatesOptimized',
905
899
  candidates: results.map(a => a.selector),
906
900
  slot: details.slot,
@@ -910,7 +904,7 @@ const onOptimizeCandidates = function(details) {
910
904
  /******************************************************************************/
911
905
 
912
906
  const showDialog = function(options) {
913
- vAPI.MessagingConnection.sendTo(epickerConnectionId, {
907
+ pickerFramePort.postMessage({
914
908
  what: 'showDialog',
915
909
  url: self.location.href,
916
910
  netFilters: netFilterCandidates,
@@ -933,9 +927,9 @@ const elementFromPoint = (( ) => {
933
927
  } else {
934
928
  return null;
935
929
  }
936
- if ( !pickerRoot ) { return null; }
937
- const magicAttr = `${vAPI.sessionId}-clickblind`;
938
- pickerRoot.setAttribute(magicAttr, '');
930
+ if ( !pickerFrame ) { return null; }
931
+ const magicAttr = `${pickerUniqueId}-clickblind`;
932
+ pickerFrame.setAttribute(magicAttr, '');
939
933
  let elem = document.elementFromPoint(x, y);
940
934
  if (
941
935
  elem === null || /* to skip following tests */
@@ -949,7 +943,7 @@ const elementFromPoint = (( ) => {
949
943
  elem = null;
950
944
  }
951
945
  // https://github.com/uBlockOrigin/uBlock-issues/issues/380
952
- pickerRoot.removeAttribute(magicAttr);
946
+ pickerFrame.removeAttribute(magicAttr);
953
947
  return elem;
954
948
  };
955
949
  })();
@@ -1065,7 +1059,7 @@ const onViewportChanged = function() {
1065
1059
  // Auto-select a specific target, if any, and if possible
1066
1060
 
1067
1061
  const startPicker = function() {
1068
- pickerRoot.focus();
1062
+ pickerFrame.focus();
1069
1063
 
1070
1064
  self.addEventListener('scroll', onViewportChanged, { passive: true });
1071
1065
  self.addEventListener('resize', onViewportChanged, { passive: true });
@@ -1102,7 +1096,7 @@ const startPicker = function() {
1102
1096
  if ( attr === undefined ) { return; }
1103
1097
  const elems = document.getElementsByTagName(tagName);
1104
1098
  for ( const elem of elems ) {
1105
- if ( elem === pickerRoot ) { continue; }
1099
+ if ( elem === pickerFrame ) { continue; }
1106
1100
  const srcs = resourceURLsFromElement(elem);
1107
1101
  if (
1108
1102
  (srcs.length !== 0 && srcs.includes(url) === false) ||
@@ -1141,25 +1135,29 @@ const quitPicker = function() {
1141
1135
  self.removeEventListener('resize', onViewportChanged, { passive: true });
1142
1136
  self.removeEventListener('keydown', onKeyPressed, true);
1143
1137
  vAPI.shutdown.remove(quitPicker);
1144
- vAPI.MessagingConnection.disconnectFrom(epickerConnectionId);
1145
- vAPI.MessagingConnection.removeListener(onConnectionMessage);
1138
+ if ( pickerFramePort ) {
1139
+ pickerFramePort.close();
1140
+ pickerFramePort = null;
1141
+ }
1142
+ if ( pickerFrame ) {
1143
+ pickerFrame.remove();
1144
+ pickerFrame = null;
1145
+ }
1146
1146
  vAPI.userStylesheet.remove(pickerCSS);
1147
1147
  vAPI.userStylesheet.apply();
1148
-
1149
- if ( pickerRoot === null ) { return; }
1150
-
1151
- pickerRoot.remove();
1152
- pickerRoot = null;
1153
-
1148
+ vAPI.pickerFrame = false;
1154
1149
  self.focus();
1155
1150
  };
1156
1151
 
1152
+ vAPI.shutdown.add(quitPicker);
1153
+
1157
1154
  /******************************************************************************/
1158
1155
 
1159
1156
  const onDialogMessage = function(msg) {
1160
1157
  switch ( msg.what ) {
1161
1158
  case 'start':
1162
1159
  startPicker();
1160
+ if ( pickerFramePort === null ) { break; }
1163
1161
  if ( targetElements.length === 0 ) {
1164
1162
  highlightElements([], true);
1165
1163
  }
@@ -1176,7 +1174,7 @@ const onDialogMessage = function(msg) {
1176
1174
  const resultset = filterToDOMInterface.queryAll(msg) || [];
1177
1175
  highlightElements(resultset.map(a => a.elem), true);
1178
1176
  if ( msg.filter === '!' ) { break; }
1179
- vAPI.MessagingConnection.sendTo(epickerConnectionId, {
1177
+ pickerFramePort.postMessage({
1180
1178
  what: 'resultsetDetails',
1181
1179
  count: resultset.length,
1182
1180
  opt: resultset.length !== 0 ? resultset[0].opt : undefined,
@@ -1215,23 +1213,6 @@ const onDialogMessage = function(msg) {
1215
1213
 
1216
1214
  /******************************************************************************/
1217
1215
 
1218
- const onConnectionMessage = function(msg) {
1219
- if ( msg.from !== `epickerDialog-${epickerId}` ) { return; }
1220
- switch ( msg.what ) {
1221
- case 'connectionRequested':
1222
- epickerConnectionId = msg.id;
1223
- return true;
1224
- case 'connectionBroken':
1225
- quitPicker();
1226
- break;
1227
- case 'connectionMessage':
1228
- onDialogMessage(msg.payload);
1229
- break;
1230
- }
1231
- };
1232
-
1233
- /******************************************************************************/
1234
-
1235
1216
  // epicker-ui.html will be injected in the page through an iframe, and
1236
1217
  // is a sandboxed so as to prevent the page from interfering with its
1237
1218
  // content and behavior.
@@ -1249,25 +1230,6 @@ const onConnectionMessage = function(msg) {
1249
1230
  // of the iframe, and cannot interfere with its style properties. However the
1250
1231
  // page can remove the iframe.
1251
1232
 
1252
- // We need extra messaging capabilities + fetch/process picker arguments.
1253
- {
1254
- const results = await Promise.all([
1255
- vAPI.messaging.extend(),
1256
- vAPI.messaging.send('elementPicker', { what: 'elementPickerArguments' }),
1257
- ]);
1258
- if ( results[0] !== true ) { return; }
1259
- pickerBootArgs = results[1];
1260
- if ( typeof pickerBootArgs !== 'object' || pickerBootArgs === null ) {
1261
- return;
1262
- }
1263
- // Restore net filter union data if origin is the same.
1264
- const eprom = pickerBootArgs.eprom || null;
1265
- if ( eprom !== null && eprom.lastNetFilterSession === lastNetFilterSession ) {
1266
- lastNetFilterHostname = eprom.lastNetFilterHostname || '';
1267
- lastNetFilterUnion = eprom.lastNetFilterUnion || '';
1268
- }
1269
- }
1270
-
1271
1233
  // The DOM filterer will not be present when cosmetic filtering is disabled.
1272
1234
  const noCosmeticFiltering =
1273
1235
  vAPI.domFilterer instanceof Object === false ||
@@ -1302,17 +1264,17 @@ const pickerCSSStyle = [
1302
1264
  'width: 100%',
1303
1265
  'z-index: 2147483647',
1304
1266
  ''
1305
- ];
1267
+ ].join(' !important;\n');
1306
1268
 
1307
1269
 
1308
1270
  const pickerCSS = `
1309
- :root > [${vAPI.sessionId}] {
1310
- ${pickerCSSStyle.join(' !important;')}
1271
+ :root > [${pickerUniqueId}] {
1272
+ ${pickerCSSStyle}
1311
1273
  }
1312
- :root > [${vAPI.sessionId}-loaded] {
1274
+ :root > [${pickerUniqueId}-loaded] {
1313
1275
  visibility: visible !important;
1314
1276
  }
1315
- :root [${vAPI.sessionId}-clickblind] {
1277
+ :root [${pickerUniqueId}-clickblind] {
1316
1278
  pointer-events: none !important;
1317
1279
  }
1318
1280
  `;
@@ -1320,24 +1282,53 @@ const pickerCSS = `
1320
1282
  vAPI.userStylesheet.add(pickerCSS);
1321
1283
  vAPI.userStylesheet.apply();
1322
1284
 
1323
- pickerRoot = document.createElement('iframe');
1324
- pickerRoot.setAttribute(vAPI.sessionId, '');
1325
- document.documentElement.append(pickerRoot);
1326
-
1327
- vAPI.shutdown.add(quitPicker);
1328
-
1329
- vAPI.MessagingConnection.addListener(onConnectionMessage);
1285
+ let pickerBootArgs;
1286
+ let pickerFramePort = null;
1330
1287
 
1331
- {
1288
+ const bootstrap = async ( ) => {
1289
+ pickerBootArgs = await vAPI.messaging.send('elementPicker', {
1290
+ what: 'elementPickerArguments',
1291
+ });
1292
+ if ( typeof pickerBootArgs !== 'object' ) { return; }
1293
+ if ( pickerBootArgs === null ) { return; }
1294
+ // Restore net filter union data if origin is the same.
1295
+ const eprom = pickerBootArgs.eprom || null;
1296
+ if ( eprom !== null && eprom.lastNetFilterSession === lastNetFilterSession ) {
1297
+ lastNetFilterHostname = eprom.lastNetFilterHostname || '';
1298
+ lastNetFilterUnion = eprom.lastNetFilterUnion || '';
1299
+ }
1332
1300
  const url = new URL(pickerBootArgs.pickerURL);
1333
- url.searchParams.set('epid', epickerId);
1334
1301
  if ( pickerBootArgs.zap ) {
1335
1302
  url.searchParams.set('zap', '1');
1336
1303
  }
1337
- pickerRoot.addEventListener("load", function() {
1338
- pickerRoot.setAttribute(`${vAPI.sessionId}-loaded`, "");
1304
+ return new Promise(resolve => {
1305
+ const iframe = document.createElement('iframe');
1306
+ iframe.setAttribute(pickerUniqueId, '');
1307
+ document.documentElement.append(iframe);
1308
+ iframe.addEventListener('load', ( ) => {
1309
+ iframe.setAttribute(`${pickerUniqueId}-loaded`, '');
1310
+ const channel = new MessageChannel();
1311
+ pickerFramePort = channel.port1;
1312
+ pickerFramePort.onmessage = ev => {
1313
+ onDialogMessage(ev.data || {});
1314
+ };
1315
+ pickerFramePort.onmessageerror = ( ) => {
1316
+ quitPicker();
1317
+ };
1318
+ iframe.contentWindow.postMessage(
1319
+ { what: 'epickerStart' },
1320
+ url.href,
1321
+ [ channel.port2 ]
1322
+ );
1323
+ resolve(iframe);
1324
+ }, { once: true });
1325
+ iframe.contentWindow.location = url.href;
1339
1326
  });
1340
- pickerRoot.src = url.href;
1327
+ };
1328
+
1329
+ let pickerFrame = await bootstrap();
1330
+ if ( Boolean(pickerFrame) === false ) {
1331
+ quitPicker();
1341
1332
  }
1342
1333
 
1343
1334
  /******************************************************************************/
@@ -1,6 +1,6 @@
1
1
  /*******************************************************************************
2
2
 
3
- uBlock Origin - a browser extension to block requests.
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
@@ -1,6 +1,6 @@
1
1
  /*******************************************************************************
2
2
 
3
- uBlock Origin - a browser extension to block requests.
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 browser extension to block requests.
3
+ uBlock Origin - a comprehensive, efficient content blocker
4
4
  Copyright (C) 2015-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 browser extension to block requests.
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 browser extension to block requests.
3
+ uBlock Origin - a comprehensive, efficient content blocker
4
4
  Copyright (C) 2018-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 browser extension to block requests.
3
+ uBlock Origin - a comprehensive, efficient content blocker
4
4
  Copyright (C) 2015-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 browser extension to block requests.
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
@@ -51,11 +51,28 @@ function updateStockLists(target) {
51
51
  if ( updateURL.hostname !== 'ublockorigin.github.io') { return; }
52
52
  if ( updateURL.pathname !== '/uAssets/update-lists.html') { return; }
53
53
  const listkeys = updateURL.searchParams.get('listkeys') || '';
54
- if ( listkeys === '' ) { return true; }
54
+ if ( listkeys === '' ) { return; }
55
+ let auto = true;
56
+ const manual = updateURL.searchParams.get('manual');
57
+ if ( manual === '1' ) {
58
+ auto = false;
59
+ } else if ( /^\d{6}$/.test(`${manual}`) ) {
60
+ const year = parseInt(manual.slice(0,2)) || 0;
61
+ const month = parseInt(manual.slice(2,4)) || 0;
62
+ const day = parseInt(manual.slice(4,6)) || 0;
63
+ if ( year !== 0 && month !== 0 && day !== 0 ) {
64
+ const date = new Date();
65
+ date.setUTCFullYear(2000 + year, month - 1, day);
66
+ date.setUTCHours(0);
67
+ const then = date.getTime() / 1000 / 3600;
68
+ const now = Date.now() / 1000 / 3600;
69
+ auto = then < (now - 48) || then > (now + 48);
70
+ }
71
+ }
55
72
  vAPI.messaging.send('scriptlets', {
56
73
  what: 'updateLists',
57
74
  listkeys,
58
- manual: updateURL.searchParams.get('manual') && true || false,
75
+ auto,
59
76
  });
60
77
  return true;
61
78
  } catch (_) {
@@ -1,6 +1,6 @@
1
1
  /*******************************************************************************
2
2
 
3
- uBlock Origin - a browser extension to block requests.
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 browser extension to block requests.
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
@@ -39,17 +39,18 @@ import './tab.js';
39
39
  import './ublock.js';
40
40
  import './utils.js';
41
41
 
42
+ import io from './assets.js';
43
+ import µb from './background.js';
44
+ import { filteringBehaviorChanged } from './broadcast.js';
42
45
  import cacheStorage from './cachestorage.js';
46
+ import { ubolog } from './console.js';
43
47
  import contextMenu from './contextmenu.js';
44
- import io from './assets.js';
45
48
  import lz4Codec from './lz4.js';
46
- import staticExtFilteringEngine from './static-ext-filtering.js';
49
+ import { redirectEngine } from './redirect-engine.js';
47
50
  import staticFilteringReverseLookup from './reverselookup.js';
51
+ import staticExtFilteringEngine from './static-ext-filtering.js';
48
52
  import staticNetFilteringEngine from './static-net-filtering.js';
49
- import µb from './background.js';
50
53
  import webRequest from './traffic.js';
51
- import { redirectEngine } from './redirect-engine.js';
52
- import { ubolog } from './console.js';
53
54
 
54
55
  import {
55
56
  permanentFirewall,
@@ -62,13 +63,6 @@ import {
62
63
 
63
64
  /******************************************************************************/
64
65
 
65
- // Load all: executed once.
66
-
67
- (async ( ) => {
68
- // >>>>> start of private scope
69
-
70
- /******************************************************************************/
71
-
72
66
  vAPI.app.onShutdown = ( ) => {
73
67
  staticFilteringReverseLookup.shutdown();
74
68
  io.updateStop();
@@ -311,10 +305,10 @@ const onHiddenSettingsReady = async ( ) => {
311
305
  }
312
306
 
313
307
  // Maybe override default cache storage
314
- const cacheBackend = await cacheStorage.select(
308
+ µb.supportStats.cacheBackend = await cacheStorage.select(
315
309
  µb.hiddenSettings.cacheStorageAPI
316
310
  );
317
- ubolog(`Backend storage for cache will be ${cacheBackend}`);
311
+ ubolog(`Backend storage for cache will be ${µb.supportStats.cacheBackend}`);
318
312
  };
319
313
 
320
314
  /******************************************************************************/
@@ -378,6 +372,9 @@ const createDefaultProps = ( ) => {
378
372
 
379
373
  /******************************************************************************/
380
374
 
375
+ (async ( ) => {
376
+ // >>>>> start of async/await scope
377
+
381
378
  try {
382
379
  ubolog(`Start sequence of loading storage-based data ${Date.now()-vAPI.T0} ms after launch`);
383
380
 
@@ -453,7 +450,7 @@ if ( selfieIsValid !== true ) {
453
450
 
454
451
  // Flush memory cache -- unsure whether the browser does this internally
455
452
  // when loading a new extension.
456
- µb.filteringBehaviorChanged();
453
+ filteringBehaviorChanged();
457
454
 
458
455
  // Final initialization steps after all needed assets are in memory.
459
456
 
@@ -477,11 +474,11 @@ lz4Codec.relinquish();
477
474
  // https://github.com/chrisaljoudi/uBlock/issues/184
478
475
  // Check for updates not too far in the future.
479
476
  io.addObserver(µb.assetObserver.bind(µb));
480
- µb.scheduleAssetUpdater(
481
- µb.userSettings.autoUpdate
477
+ µb.scheduleAssetUpdater({
478
+ updateDelay: µb.userSettings.autoUpdate
482
479
  ? µb.hiddenSettings.autoUpdateDelayAfterLaunch * 1000
483
480
  : 0
484
- );
481
+ });
485
482
 
486
483
  // Force an update of the context menu according to the currently
487
484
  // active tab.
@@ -505,5 +502,7 @@ if ( selfieIsValid ) {
505
502
  }
506
503
  ubolog(`All ready ${µb.supportStats.allReadyAfter} after launch`);
507
504
 
508
- // <<<<< end of private scope
505
+ µb.isReadyResolve();
506
+
507
+ // <<<<< end of async/await scope
509
508
  })();
@@ -1,6 +1,6 @@
1
1
  /*******************************************************************************
2
2
 
3
- uBlock Origin - a browser extension to block requests.
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 browser extension to block requests.
3
+ uBlock Origin - a comprehensive, efficient content blocker
4
4
  Copyright (C) 2017-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 browser extension to block requests.
3
+ uBlock Origin - a comprehensive, efficient content blocker
4
4
  Copyright (C) 2017-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 browser extension to block requests.
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 browser extension to block requests.
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
@@ -273,7 +273,7 @@ export const nodeTypeFromOptionName = new Map([
273
273
  [ 'shide', NODE_TYPE_NET_OPTION_NAME_SHIDE ],
274
274
  /* synonym */ [ 'specifichide', NODE_TYPE_NET_OPTION_NAME_SHIDE ],
275
275
  [ 'to', NODE_TYPE_NET_OPTION_NAME_TO ],
276
- [ 'urltransform', NODE_TYPE_NET_OPTION_NAME_URLTRANSFORM ],
276
+ [ 'uritransform', NODE_TYPE_NET_OPTION_NAME_URLTRANSFORM ],
277
277
  [ 'xhr', NODE_TYPE_NET_OPTION_NAME_XHR ],
278
278
  /* synonym */ [ 'xmlhttprequest', NODE_TYPE_NET_OPTION_NAME_XHR ],
279
279
  [ 'webrtc', NODE_TYPE_NET_OPTION_NAME_WEBRTC ],
@@ -1224,6 +1224,7 @@ export class AstFilterParser {
1224
1224
  ? NODE_TYPE_PREPARSE_DIRECTIVE_IF_VALUE
1225
1225
  : NODE_TYPE_PREPARSE_DIRECTIVE_VALUE;
1226
1226
  const next = this.allocTypedNode(type, directiveEnd, parentEnd);
1227
+ this.addNodeToRegister(type, next);
1227
1228
  this.linkRight(head, next);
1228
1229
  if ( type === NODE_TYPE_PREPARSE_DIRECTIVE_IF_VALUE ) {
1229
1230
  const rawToken = this.getNodeString(next).trim();
@@ -3066,6 +3067,7 @@ export const netOptionTokenDescriptors = new Map([
3066
3067
  [ 'object', { canNegate: true } ],
3067
3068
  /* synonym */ [ 'object-subrequest', { canNegate: true } ],
3068
3069
  [ 'other', { canNegate: true } ],
3070
+ [ 'permissions', { mustAssign: true } ],
3069
3071
  [ 'ping', { canNegate: true } ],
3070
3072
  /* synonym */ [ 'beacon', { canNegate: true } ],
3071
3073
  [ 'popunder', { } ],
@@ -3080,7 +3082,7 @@ export const netOptionTokenDescriptors = new Map([
3080
3082
  [ 'shide', { } ],
3081
3083
  /* synonym */ [ 'specifichide', { } ],
3082
3084
  [ 'to', { mustAssign: true } ],
3083
- [ 'urltransform', { mustAssign: true } ],
3085
+ [ 'uritransform', { mustAssign: true } ],
3084
3086
  [ 'xhr', { canNegate: true } ],
3085
3087
  /* synonym */ [ 'xmlhttprequest', { canNegate: true } ],
3086
3088
  [ 'webrtc', { } ],