@browserless.io/browserless 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/README.md +55 -36
  3. package/build/config.d.ts +2 -2
  4. package/build/config.js +3 -3
  5. package/build/data/classes.json +1 -1
  6. package/build/data/selectors.json +1 -1
  7. package/build/http.d.ts +1 -0
  8. package/build/http.js +1 -0
  9. package/build/routes/chrome/http/content.post.body.json +8 -8
  10. package/build/routes/chrome/http/pdf.post.body.json +8 -8
  11. package/build/routes/chrome/http/scrape.post.body.json +8 -8
  12. package/build/routes/chrome/http/screenshot.post.body.json +9 -9
  13. package/build/routes/chromium/http/content.post.body.json +8 -8
  14. package/build/routes/chromium/http/pdf.post.body.json +8 -8
  15. package/build/routes/chromium/http/scrape.post.body.json +8 -8
  16. package/build/routes/chromium/http/screenshot.post.body.json +9 -9
  17. package/build/routes/management/http/active.get.d.ts +16 -0
  18. package/build/routes/management/http/active.get.js +17 -0
  19. package/build/routes/management/tests/management.spec.js +7 -0
  20. package/build/server.js +1 -1
  21. package/build/types.d.ts +6 -4
  22. package/build/types.js +1 -0
  23. package/build/utils.d.ts +1 -1
  24. package/docker/base/Dockerfile +1 -1
  25. package/extensions/ublock/1p-filters.html +4 -3
  26. package/extensions/ublock/3p-filters.html +3 -3
  27. package/extensions/ublock/_locales/ar/messages.json +16 -4
  28. package/extensions/ublock/_locales/az/messages.json +16 -4
  29. package/extensions/ublock/_locales/be/messages.json +19 -7
  30. package/extensions/ublock/_locales/bg/messages.json +16 -4
  31. package/extensions/ublock/_locales/bn/messages.json +33 -21
  32. package/extensions/ublock/_locales/br_FR/messages.json +33 -21
  33. package/extensions/ublock/_locales/bs/messages.json +16 -4
  34. package/extensions/ublock/_locales/ca/messages.json +16 -4
  35. package/extensions/ublock/_locales/cs/messages.json +16 -4
  36. package/extensions/ublock/_locales/cv/messages.json +16 -4
  37. package/extensions/ublock/_locales/cy/messages.json +16 -4
  38. package/extensions/ublock/_locales/da/messages.json +21 -9
  39. package/extensions/ublock/_locales/de/messages.json +17 -5
  40. package/extensions/ublock/_locales/el/messages.json +16 -4
  41. package/extensions/ublock/_locales/en/messages.json +16 -4
  42. package/extensions/ublock/_locales/en_GB/messages.json +16 -4
  43. package/extensions/ublock/_locales/eo/messages.json +17 -5
  44. package/extensions/ublock/_locales/es/messages.json +16 -4
  45. package/extensions/ublock/_locales/et/messages.json +16 -4
  46. package/extensions/ublock/_locales/eu/messages.json +16 -4
  47. package/extensions/ublock/_locales/fa/messages.json +24 -12
  48. package/extensions/ublock/_locales/fi/messages.json +16 -4
  49. package/extensions/ublock/_locales/fil/messages.json +16 -4
  50. package/extensions/ublock/_locales/fr/messages.json +16 -4
  51. package/extensions/ublock/_locales/fy/messages.json +16 -4
  52. package/extensions/ublock/_locales/gl/messages.json +16 -4
  53. package/extensions/ublock/_locales/gu/messages.json +16 -4
  54. package/extensions/ublock/_locales/he/messages.json +25 -13
  55. package/extensions/ublock/_locales/hi/messages.json +31 -19
  56. package/extensions/ublock/_locales/hr/messages.json +16 -4
  57. package/extensions/ublock/_locales/hu/messages.json +16 -4
  58. package/extensions/ublock/_locales/hy/messages.json +17 -5
  59. package/extensions/ublock/_locales/id/messages.json +16 -4
  60. package/extensions/ublock/_locales/it/messages.json +17 -5
  61. package/extensions/ublock/_locales/ja/messages.json +16 -4
  62. package/extensions/ublock/_locales/ka/messages.json +16 -4
  63. package/extensions/ublock/_locales/kk/messages.json +16 -4
  64. package/extensions/ublock/_locales/kn/messages.json +74 -62
  65. package/extensions/ublock/_locales/ko/messages.json +16 -4
  66. package/extensions/ublock/_locales/lt/messages.json +23 -11
  67. package/extensions/ublock/_locales/lv/messages.json +16 -4
  68. package/extensions/ublock/_locales/mk/messages.json +16 -4
  69. package/extensions/ublock/_locales/ml/messages.json +19 -7
  70. package/extensions/ublock/_locales/mr/messages.json +16 -4
  71. package/extensions/ublock/_locales/ms/messages.json +16 -4
  72. package/extensions/ublock/_locales/nb/messages.json +16 -4
  73. package/extensions/ublock/_locales/nl/messages.json +16 -4
  74. package/extensions/ublock/_locales/no/messages.json +16 -4
  75. package/extensions/ublock/_locales/oc/messages.json +16 -4
  76. package/extensions/ublock/_locales/pa/messages.json +16 -4
  77. package/extensions/ublock/_locales/pl/messages.json +17 -5
  78. package/extensions/ublock/_locales/pt_BR/messages.json +16 -4
  79. package/extensions/ublock/_locales/pt_PT/messages.json +16 -4
  80. package/extensions/ublock/_locales/ro/messages.json +17 -5
  81. package/extensions/ublock/_locales/ru/messages.json +16 -4
  82. package/extensions/ublock/_locales/si/messages.json +16 -4
  83. package/extensions/ublock/_locales/sk/messages.json +16 -4
  84. package/extensions/ublock/_locales/sl/messages.json +16 -4
  85. package/extensions/ublock/_locales/so/messages.json +16 -4
  86. package/extensions/ublock/_locales/sq/messages.json +16 -4
  87. package/extensions/ublock/_locales/sr/messages.json +16 -4
  88. package/extensions/ublock/_locales/sv/messages.json +20 -8
  89. package/extensions/ublock/_locales/sw/messages.json +16 -4
  90. package/extensions/ublock/_locales/ta/messages.json +16 -4
  91. package/extensions/ublock/_locales/te/messages.json +16 -4
  92. package/extensions/ublock/_locales/th/messages.json +42 -30
  93. package/extensions/ublock/_locales/tr/messages.json +19 -7
  94. package/extensions/ublock/_locales/uk/messages.json +16 -4
  95. package/extensions/ublock/_locales/ur/messages.json +16 -4
  96. package/extensions/ublock/_locales/vi/messages.json +16 -4
  97. package/extensions/ublock/_locales/zh_CN/messages.json +16 -4
  98. package/extensions/ublock/_locales/zh_TW/messages.json +42 -30
  99. package/extensions/ublock/assets/assets.json +95 -78
  100. package/extensions/ublock/assets/resources/scriptlets.js +70 -24
  101. package/extensions/ublock/assets/thirdparties/easylist/easylist.txt +6258 -3453
  102. package/extensions/ublock/assets/thirdparties/easylist/easyprivacy.txt +277 -40
  103. package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/serverlist +8 -32
  104. package/extensions/ublock/assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat +107 -12
  105. package/extensions/ublock/assets/thirdparties/urlhaus-filter/urlhaus-filter-online.txt +1160 -954
  106. package/extensions/ublock/assets/ublock/badlists.txt +1 -2
  107. package/extensions/ublock/assets/ublock/badware.min.txt +395 -270
  108. package/extensions/ublock/assets/ublock/filters.min.txt +1176 -1238
  109. package/extensions/ublock/assets/ublock/privacy.min.txt +32 -31
  110. package/extensions/ublock/assets/ublock/quick-fixes.min.txt +120 -110
  111. package/extensions/ublock/assets/ublock/unbreak.min.txt +75 -36
  112. package/extensions/ublock/css/1p-filters.css +2 -1
  113. package/extensions/ublock/css/3p-filters.css +1 -16
  114. package/extensions/ublock/css/advanced-settings.css +1 -0
  115. package/extensions/ublock/css/asset-viewer.css +1 -0
  116. package/extensions/ublock/css/code-viewer.css +1 -0
  117. package/extensions/ublock/css/codemirror.css +37 -10
  118. package/extensions/ublock/css/common.css +36 -2
  119. package/extensions/ublock/css/dashboard.css +9 -3
  120. package/extensions/ublock/css/devtools.css +1 -0
  121. package/extensions/ublock/css/document-blocked.css +3 -3
  122. package/extensions/ublock/css/dom-inspector.css +1 -0
  123. package/extensions/ublock/css/dyna-rules.css +1 -0
  124. package/extensions/ublock/css/epicker-ui.css +76 -66
  125. package/extensions/ublock/css/fa-icons.css +1 -0
  126. package/extensions/ublock/css/logger-ui.css +2 -0
  127. package/extensions/ublock/css/popup-fenix.css +1 -0
  128. package/extensions/ublock/css/whitelist.css +1 -0
  129. package/extensions/ublock/dashboard.html +20 -13
  130. package/extensions/ublock/devtools.html +2 -0
  131. package/extensions/ublock/dyna-rules.html +2 -2
  132. package/extensions/ublock/img/flags-of-the-world/np.png +0 -0
  133. package/extensions/ublock/img/fontawesome/fontawesome-defs.svg +1 -0
  134. package/extensions/ublock/js/1p-filters.js +72 -23
  135. package/extensions/ublock/js/3p-filters.js +71 -25
  136. package/extensions/ublock/js/asset-viewer.js +1 -0
  137. package/extensions/ublock/js/assets.js +83 -89
  138. package/extensions/ublock/js/background.js +20 -27
  139. package/extensions/ublock/js/base64-custom.js +1 -102
  140. package/extensions/ublock/js/benchmarks.js +36 -21
  141. package/extensions/ublock/js/biditrie.js +8 -23
  142. package/extensions/ublock/js/broadcast.js +2 -4
  143. package/extensions/ublock/js/cachestorage.js +594 -396
  144. package/extensions/ublock/js/codemirror/search.js +49 -37
  145. package/extensions/ublock/js/codemirror/ubo-static-filtering.js +233 -215
  146. package/extensions/ublock/js/contentscript-extra.js +31 -1
  147. package/extensions/ublock/js/cosmetic-filtering.js +35 -33
  148. package/extensions/ublock/js/dashboard.js +11 -7
  149. package/extensions/ublock/js/devtools.js +22 -0
  150. package/extensions/ublock/js/dom.js +2 -2
  151. package/extensions/ublock/js/dyna-rules.js +17 -16
  152. package/extensions/ublock/js/epicker-ui.js +41 -16
  153. package/extensions/ublock/js/fa-icons.js +1 -0
  154. package/extensions/ublock/js/hntrie.js +10 -25
  155. package/extensions/ublock/js/i18n.js +15 -15
  156. package/extensions/ublock/js/logger-ui.js +9 -6
  157. package/extensions/ublock/js/messaging.js +51 -26
  158. package/extensions/ublock/js/pagestore.js +21 -23
  159. package/extensions/ublock/js/popup-fenix.js +35 -22
  160. package/extensions/ublock/js/redirect-engine.js +15 -30
  161. package/extensions/ublock/js/reverselookup.js +1 -1
  162. package/extensions/ublock/js/s14e-serializer.js +1405 -0
  163. package/extensions/ublock/js/scriptlet-filtering-core.js +1 -1
  164. package/extensions/ublock/js/scriptlets/epicker.js +27 -18
  165. package/extensions/ublock/js/settings.js +32 -21
  166. package/extensions/ublock/js/start.js +121 -62
  167. package/extensions/ublock/js/static-ext-filtering-db.js +6 -6
  168. package/extensions/ublock/js/static-ext-filtering.js +17 -28
  169. package/extensions/ublock/js/static-filtering-parser.js +26 -4
  170. package/extensions/ublock/js/static-net-filtering.js +69 -168
  171. package/extensions/ublock/js/storage.js +178 -155
  172. package/extensions/ublock/js/traffic.js +11 -7
  173. package/extensions/ublock/js/vapi-background.js +49 -62
  174. package/extensions/ublock/js/vapi-client.js +13 -16
  175. package/extensions/ublock/js/webext.js +10 -2
  176. package/extensions/ublock/js/whitelist.js +27 -25
  177. package/extensions/ublock/lib/publicsuffixlist/publicsuffixlist.js +3 -7
  178. package/extensions/ublock/manifest.json +2 -1
  179. package/extensions/ublock/web_accessible_resources/epicker-ui.html +5 -8
  180. package/extensions/ublock/whitelist.html +3 -4
  181. package/package.json +12 -12
  182. package/src/config.ts +3 -4
  183. package/src/http.ts +1 -0
  184. package/src/routes/management/http/active.get.ts +30 -0
  185. package/src/routes/management/tests/management.spec.ts +13 -0
  186. package/src/server.ts +1 -1
  187. package/src/types.ts +2 -1
  188. package/static/docs/swagger.json +57 -11
  189. package/static/docs/swagger.min.json +56 -10
  190. package/static/function/client.js +4155 -3350
  191. package/extensions/ublock/_locales/ku/messages.json +0 -1294
@@ -291,21 +291,21 @@ if ( isBackgroundProcess !== true ) {
291
291
 
292
292
  const unicodeFlagToImageSrc = new Map([
293
293
  [ '🇦🇱', 'al' ], [ '🇦🇷', 'ar' ], [ '🇦🇹', 'at' ], [ '🇧🇦', 'ba' ],
294
- [ '🇧🇬', 'bg' ], [ '🇧🇷', 'br' ], [ '🇨🇦', 'ca' ], [ '🇨🇭', 'ch' ],
295
- [ '🇨🇳', 'cn' ], [ '🇨🇴', 'co' ], [ '🇨🇾', 'cy' ], [ '🇨🇿', 'cz' ],
296
- [ '🇩🇪', 'de' ], [ '🇩🇰', 'dk' ], [ '🇩🇿', 'dz' ], [ '🇪🇪', 'ee' ],
297
- [ '🇪🇬', 'eg' ], [ '🇪🇸', 'es' ], [ '🇫🇮', 'fi' ], [ '🇫🇴', 'fo' ],
298
- [ '🇫🇷', 'fr' ], [ '🇬🇷', 'gr' ], [ '🇭🇷', 'hr' ], [ '🇭🇺', 'hu' ],
299
- [ '🇮🇩', 'id' ], [ '🇮🇱', 'il' ], [ '🇮🇳', 'in' ], [ '🇮🇷', 'ir' ],
300
- [ '🇮🇸', 'is' ], [ '🇮🇹', 'it' ], [ '🇯🇵', 'jp' ], [ '🇰🇷', 'kr' ],
301
- [ '🇰🇿', 'kz' ], [ '🇱🇰', 'lk' ], [ '🇱🇹', 'lt' ], [ '🇱🇻', 'lv' ],
302
- [ '🇲🇦', 'ma' ], [ '🇲🇩', 'md' ], [ '🇲🇰', 'mk' ], [ '🇲🇽', 'mx' ],
303
- [ '🇲🇾', 'my' ], [ '🇳🇱', 'nl' ], [ '🇳🇴', 'no' ], [ '🇳🇵', 'np' ],
304
- [ '🇵🇱', 'pl' ], [ '🇵🇹', 'pt' ], [ '🇷🇴', 'ro' ], [ '🇷🇸', 'rs' ],
305
- [ '🇷🇺', 'ru' ], [ '🇸🇦', 'sa' ], [ '🇸🇮', 'si' ], [ '🇸🇰', 'sk' ],
306
- [ '🇸🇪', 'se' ], [ '🇸🇷', 'sr' ], [ '🇹🇭', 'th' ], [ '🇹🇯', 'tj' ],
307
- [ '🇹🇼', 'tw' ], [ '🇹🇷', 'tr' ], [ '🇺🇦', 'ua' ], [ '🇺🇿', 'uz' ],
308
- [ '🇻🇳', 'vn' ], [ '🇽🇰', 'xk' ],
294
+ [ '🇧🇪', 'be' ], [ '🇧🇬', 'bg' ], [ '🇧🇷', 'br' ], [ '🇨🇦', 'ca' ],
295
+ [ '🇨🇭', 'ch' ], [ '🇨🇳', 'cn' ], [ '🇨🇴', 'co' ], [ '🇨🇾', 'cy' ],
296
+ [ '🇨🇿', 'cz' ], [ '🇩🇪', 'de' ], [ '🇩🇰', 'dk' ], [ '🇩🇿', 'dz' ],
297
+ [ '🇪🇪', 'ee' ], [ '🇪🇬', 'eg' ], [ '🇪🇸', 'es' ], [ '🇫🇮', 'fi' ],
298
+ [ '🇫🇴', 'fo' ], [ '🇫🇷', 'fr' ], [ '🇬🇷', 'gr' ], [ '🇭🇷', 'hr' ],
299
+ [ '🇭🇺', 'hu' ], [ '🇮🇩', 'id' ], [ '🇮🇱', 'il' ], [ '🇮🇳', 'in' ],
300
+ [ '🇮🇷', 'ir' ], [ '🇮🇸', 'is' ], [ '🇮🇹', 'it' ], [ '🇯🇵', 'jp' ],
301
+ [ '🇰🇷', 'kr' ], [ '🇰🇿', 'kz' ], [ '🇱🇰', 'lk' ], [ '🇱🇹', 'lt' ],
302
+ [ '🇱🇻', 'lv' ], [ '🇲🇦', 'ma' ], [ '🇲🇩', 'md' ], [ '🇲🇰', 'mk' ],
303
+ [ '🇲🇽', 'mx' ], [ '🇲🇾', 'my' ], [ '🇳🇱', 'nl' ], [ '🇳🇴', 'no' ],
304
+ [ '🇳🇵', 'np' ], [ '🇵🇱', 'pl' ], [ '🇵🇹', 'pt' ], [ '🇷🇴', 'ro' ],
305
+ [ '🇷🇸', 'rs' ], [ '🇷🇺', 'ru' ], [ '🇸🇦', 'sa' ], [ '🇸🇮', 'si' ],
306
+ [ '🇸🇰', 'sk' ], [ '🇸🇪', 'se' ], [ '🇸🇷', 'sr' ], [ '🇹🇭', 'th' ],
307
+ [ '🇹🇯', 'tj' ], [ '🇹🇼', 'tw' ], [ '🇹🇷', 'tr' ], [ '🇺🇦', 'ua' ],
308
+ [ '🇺🇿', 'uz' ], [ '🇻🇳', 'vn' ], [ '🇽🇰', 'xk' ],
309
309
  ]);
310
310
  const reUnicodeFlags = new RegExp(
311
311
  Array.from(unicodeFlagToImageSrc).map(a => a[0]).join('|'),
@@ -1341,9 +1341,7 @@ dom.on(document, 'keydown', ev => {
1341
1341
  if ( reSchemeOnly.test(value) ) {
1342
1342
  value = `|${value}`;
1343
1343
  } else {
1344
- if ( value.endsWith('/') ) {
1345
- value += '*';
1346
- } else if ( /[/?]/.test(value) === false ) {
1344
+ if ( /[/?]/.test(value) === false ) {
1347
1345
  value += '^';
1348
1346
  }
1349
1347
  value = `||${value}`;
@@ -1415,7 +1413,8 @@ dom.on(document, 'keydown', ev => {
1415
1413
  // Create static filter
1416
1414
  if ( target.id === 'createStaticFilter' ) {
1417
1415
  ev.stopPropagation();
1418
- const value = staticFilterNode().value;
1416
+ const value = staticFilterNode().value
1417
+ .replace(/^((?:@@)?\/.+\/)(\$|$)/, '$1*$2');
1419
1418
  // Avoid duplicates
1420
1419
  if ( createdStaticFilters.hasOwnProperty(value) ) { return; }
1421
1420
  createdStaticFilters[value] = true;
@@ -2011,8 +2010,12 @@ dom.on(document, 'keydown', ev => {
2011
2010
  };
2012
2011
 
2013
2012
  const toggleOn = async function(ev) {
2014
- targetRow = ev.target.closest('.canDetails');
2015
- if ( targetRow === null ) { return; }
2013
+ const clickedRow = ev.target.closest('.canDetails');
2014
+ if ( clickedRow === null ) { return; }
2015
+ if ( clickedRow === targetRow ) {
2016
+ return toggleOff();
2017
+ }
2018
+ targetRow = clickedRow;
2016
2019
  ev.stopPropagation();
2017
2020
  targetTabId = tabIdFromAttribute(targetRow);
2018
2021
  targetType = targetRow.children[COLUMN_TYPE].textContent.trim() || '';
@@ -45,6 +45,7 @@ import { dnrRulesetFromRawLists } from './static-dnr-filtering.js';
45
45
  import { i18n$ } from './i18n.js';
46
46
  import { redirectEngine } from './redirect-engine.js';
47
47
  import * as sfp from './static-filtering-parser.js';
48
+ import * as s14e from './s14e-serializer.js';
48
49
 
49
50
  import {
50
51
  permanentFirewall,
@@ -63,8 +64,6 @@ import {
63
64
  isNetworkURI,
64
65
  } from './uri-utils.js';
65
66
 
66
- import './benchmarks.js';
67
-
68
67
  /******************************************************************************/
69
68
 
70
69
  // https://github.com/uBlockOrigin/uBlock-issues/issues/710
@@ -364,8 +363,8 @@ const popupDataFromTabId = function(tabId, tabTitle) {
364
363
  colorBlindFriendly: µbus.colorBlindFriendly,
365
364
  cosmeticFilteringSwitch: false,
366
365
  firewallPaneMinimized: µbus.firewallPaneMinimized,
367
- globalAllowedRequestCount: µb.localSettings.allowedRequestCount,
368
- globalBlockedRequestCount: µb.localSettings.blockedRequestCount,
366
+ globalAllowedRequestCount: µb.requestStats.allowedCount,
367
+ globalBlockedRequestCount: µb.requestStats.blockedCount,
369
368
  fontSize: µbhs.popupFontSize,
370
369
  godMode: µbhs.filterAuthorMode,
371
370
  netFilteringSwitch: false,
@@ -379,6 +378,7 @@ const popupDataFromTabId = function(tabId, tabTitle) {
379
378
  popupPanelDisabledSections: µbhs.popupPanelDisabledSections,
380
379
  popupPanelLockedSections: µbhs.popupPanelLockedSections,
381
380
  popupPanelHeightMode: µbhs.popupPanelHeightMode,
381
+ popupPanelOrientation: µbhs.popupPanelOrientation,
382
382
  tabId,
383
383
  tabTitle,
384
384
  tooltipsDisabled: µbus.tooltipsDisabled,
@@ -925,21 +925,6 @@ const fromBase64 = function(encoded) {
925
925
  return Promise.resolve(u8array !== undefined ? u8array : encoded);
926
926
  };
927
927
 
928
- const toBase64 = function(data) {
929
- const value = data instanceof Uint8Array
930
- ? denseBase64.encode(data)
931
- : data;
932
- return Promise.resolve(value);
933
- };
934
-
935
- const compress = function(json) {
936
- return lz4Codec.encode(json, toBase64);
937
- };
938
-
939
- const decompress = function(encoded) {
940
- return lz4Codec.decode(encoded, fromBase64);
941
- };
942
-
943
928
  const onMessage = function(request, sender, callback) {
944
929
  // Cloud storage support is optional.
945
930
  if ( µb.cloudStorageSupported !== true ) {
@@ -961,15 +946,25 @@ const onMessage = function(request, sender, callback) {
961
946
  return;
962
947
 
963
948
  case 'cloudPull':
964
- request.decode = decompress;
949
+ request.decode = encoded => {
950
+ if ( s14e.isSerialized(encoded) ) {
951
+ return s14e.deserializeAsync(encoded, { thread: true });
952
+ }
953
+ // Legacy decoding: needs to be kept around for the foreseeable future.
954
+ return lz4Codec.decode(encoded, fromBase64);
955
+ };
965
956
  return vAPI.cloud.pull(request).then(result => {
966
957
  callback(result);
967
958
  });
968
959
 
969
960
  case 'cloudPush':
970
- if ( µb.hiddenSettings.cloudStorageCompression ) {
971
- request.encode = compress;
972
- }
961
+ request.encode = data => {
962
+ const options = {
963
+ compress: µb.hiddenSettings.cloudStorageCompression,
964
+ thread: true,
965
+ };
966
+ return s14e.serializeAsync(data, options);
967
+ };
973
968
  return vAPI.cloud.push(request).then(result => {
974
969
  callback(result);
975
970
  });
@@ -1456,11 +1451,23 @@ const onMessage = function(request, sender, callback) {
1456
1451
 
1457
1452
  case 'readUserFilters':
1458
1453
  return µb.loadUserFilters().then(result => {
1459
- result.trustedSource = µb.isTrustedList(µb.userFiltersPath);
1454
+ result.enabled = µb.selectedFilterLists.includes(µb.userFiltersPath);
1455
+ result.trusted = µb.isTrustedList(µb.userFiltersPath);
1460
1456
  callback(result);
1461
1457
  });
1462
1458
 
1463
1459
  case 'writeUserFilters':
1460
+ if ( request.enabled ) {
1461
+ µb.applyFilterListSelection({
1462
+ toSelect: [ µb.userFiltersPath ],
1463
+ merge: true,
1464
+ });
1465
+ } else {
1466
+ µb.applyFilterListSelection({
1467
+ toRemove: [ µb.userFiltersPath ],
1468
+ });
1469
+ }
1470
+ µb.changeUserSettings('userFiltersTrusted', request.trusted || false);
1464
1471
  return µb.saveUserFilters(request.content).then(result => {
1465
1472
  callback(result);
1466
1473
  });
@@ -1851,8 +1858,26 @@ const onMessage = function(request, sender, callback) {
1851
1858
  return;
1852
1859
 
1853
1860
  case 'snfeBenchmark':
1854
- µb.benchmarkStaticNetFiltering({ redirectEngine }).then(result => {
1855
- callback(result);
1861
+ import('/js/benchmarks.js').then(module => {
1862
+ module.benchmarkStaticNetFiltering({ redirectEngine }).then(result => {
1863
+ callback(result);
1864
+ });
1865
+ });
1866
+ return;
1867
+
1868
+ case 'cfeBenchmark':
1869
+ import('/js/benchmarks.js').then(module => {
1870
+ module.benchmarkCosmeticFiltering().then(result => {
1871
+ callback(result);
1872
+ });
1873
+ });
1874
+ return;
1875
+
1876
+ case 'sfeBenchmark':
1877
+ import('/js/benchmarks.js').then(module => {
1878
+ module.benchmarkScriptletFiltering().then(result => {
1879
+ callback(result);
1880
+ });
1856
1881
  });
1857
1882
  return;
1858
1883
 
@@ -19,17 +19,13 @@
19
19
  Home: https://github.com/gorhill/uBlock
20
20
  */
21
21
 
22
- 'use strict';
23
-
24
22
  /******************************************************************************/
25
23
 
26
- import contextMenu from './contextmenu.js';
27
- import logger from './logger.js';
28
- import staticNetFilteringEngine from './static-net-filtering.js';
29
- import µb from './background.js';
30
- import webext from './webext.js';
31
- import { orphanizeString } from './text-utils.js';
32
- import { redirectEngine } from './redirect-engine.js';
24
+ import {
25
+ domainFromHostname,
26
+ hostnameFromURI,
27
+ isNetworkURI,
28
+ } from './uri-utils.js';
33
29
 
34
30
  import {
35
31
  sessionFirewall,
@@ -37,11 +33,13 @@ import {
37
33
  sessionURLFiltering,
38
34
  } from './filtering-engines.js';
39
35
 
40
- import {
41
- domainFromHostname,
42
- hostnameFromURI,
43
- isNetworkURI,
44
- } from './uri-utils.js';
36
+ import contextMenu from './contextmenu.js';
37
+ import logger from './logger.js';
38
+ import { orphanizeString } from './text-utils.js';
39
+ import { redirectEngine } from './redirect-engine.js';
40
+ import staticNetFilteringEngine from './static-net-filtering.js';
41
+ import webext from './webext.js';
42
+ import µb from './background.js';
45
43
 
46
44
  /*******************************************************************************
47
45
 
@@ -379,11 +377,13 @@ const PageStore = class {
379
377
 
380
378
  // If we are navigating from-to same site, remember whether large
381
379
  // media elements were temporarily allowed.
382
- if (
383
- typeof this.allowLargeMediaElementsUntil !== 'number' ||
384
- tabContext.rootHostname !== this.tabHostname
385
- ) {
386
- this.allowLargeMediaElementsUntil = Date.now();
380
+ const now = Date.now();
381
+ if ( typeof this.allowLargeMediaElementsUntil !== 'number' ) {
382
+ this.allowLargeMediaElementsUntil = now;
383
+ } else if ( tabContext.rootHostname !== this.tabHostname ) {
384
+ if ( this.tabHostname.endsWith('about-scheme') === false ) {
385
+ this.allowLargeMediaElementsUntil = now;
386
+ }
387
387
  }
388
388
 
389
389
  this.tabHostname = tabContext.rootHostname;
@@ -739,10 +739,8 @@ const PageStore = class {
739
739
  aggregateAllowed += 1;
740
740
  }
741
741
  }
742
- if ( aggregateAllowed !== 0 || aggregateBlocked !== 0 ) {
743
- µb.localSettings.blockedRequestCount += aggregateBlocked;
744
- µb.localSettings.allowedRequestCount += aggregateAllowed;
745
- µb.localSettingsLastModified = now;
742
+ if ( aggregateAllowed || aggregateBlocked ) {
743
+ µb.incrementRequestStats(aggregateBlocked, aggregateAllowed);
746
744
  }
747
745
  journal.length = 0;
748
746
  }
@@ -70,6 +70,9 @@ let cachedPopupHash = '';
70
70
  const reCyrillicNonAmbiguous = /[\u0400-\u042b\u042d-\u042f\u0431\u0432\u0434\u0436-\u043d\u0442\u0444\u0446-\u0449\u044b-\u0454\u0457\u0459-\u0460\u0462-\u0474\u0476-\u04ba\u04bc\u04be-\u04ce\u04d0-\u0500\u0502-\u051a\u051c\u051e-\u052f]/;
71
71
  const reCyrillicAmbiguous = /[\u042c\u0430\u0433\u0435\u043e\u043f\u0440\u0441\u0443\u0445\u044a\u0455\u0456\u0458\u0461\u0475\u04bb\u04bd\u04cf\u0501\u051b\u051d]/;
72
72
 
73
+ const hasOwnProperty = (o, p) =>
74
+ Object.prototype.hasOwnProperty.call(o, p);
75
+
73
76
  /******************************************************************************/
74
77
 
75
78
  const cachePopupData = function(data) {
@@ -88,7 +91,7 @@ const cachePopupData = function(data) {
88
91
  return popupData;
89
92
  }
90
93
  for ( const hostname in hostnameDict ) {
91
- if ( hostnameDict.hasOwnProperty(hostname) === false ) { continue; }
94
+ if ( hasOwnProperty(hostnameDict, hostname) === false ) { continue; }
92
95
  let domain = hostnameDict[hostname].domain;
93
96
  let prefix = hostname.slice(0, 0 - domain.length - 1);
94
97
  // Prefix with space char for 1st-party hostnames: this ensure these
@@ -160,7 +163,7 @@ const formatNumber = function(count) {
160
163
  });
161
164
  if (
162
165
  intl.resolvedOptions instanceof Function &&
163
- intl.resolvedOptions().hasOwnProperty('notation')
166
+ hasOwnProperty(intl.resolvedOptions(), 'notation')
164
167
  ) {
165
168
  intlNumberFormat = intl;
166
169
  }
@@ -545,7 +548,7 @@ const renderPrivacyExposure = function() {
545
548
  if ( des === '*' || desHostnameDone.has(des) ) { continue; }
546
549
  const hnDetails = hostnameDict[des];
547
550
  const { domain, counts } = hnDetails;
548
- if ( allDomains.hasOwnProperty(domain) === false ) {
551
+ if ( hasOwnProperty(allDomains, domain) === false ) {
549
552
  allDomains[domain] = false;
550
553
  allDomainCount += 1;
551
554
  }
@@ -802,7 +805,7 @@ let renderOnce = function() {
802
805
  dom.attr('#firewall [title][data-src]', 'title', null);
803
806
  }
804
807
 
805
- // This must be done the firewall is populated
808
+ // This must be done when the firewall is populated
806
809
  if ( popupData.popupPanelHeightMode === 1 ) {
807
810
  dom.cl.add(dom.body, 'vMin');
808
811
  }
@@ -1462,6 +1465,33 @@ const getPopupData = async function(tabId, first = false) {
1462
1465
  }
1463
1466
  };
1464
1467
 
1468
+ const setOrientation = async ( ) => {
1469
+ if ( dom.cl.has(dom.root, 'mobile') ) {
1470
+ dom.cl.remove(dom.root, 'desktop');
1471
+ dom.cl.add(dom.root, 'portrait');
1472
+ return;
1473
+ }
1474
+ if ( selfURL.searchParams.get('portrait') !== null ) {
1475
+ dom.cl.remove(dom.root, 'desktop');
1476
+ dom.cl.add(dom.root, 'portrait');
1477
+ return;
1478
+ }
1479
+ if ( popupData.popupPanelOrientation === 'landscape' ) { return; }
1480
+ if ( popupData.popupPanelOrientation === 'portrait' ) {
1481
+ dom.cl.remove(dom.root, 'desktop');
1482
+ dom.cl.add(dom.root, 'portrait');
1483
+ return;
1484
+ }
1485
+ if ( dom.cl.has(dom.root, 'desktop') === false ) { return; }
1486
+ await nextFrames(8);
1487
+ const main = qs$('#main');
1488
+ const firewall = qs$('#firewall');
1489
+ const minWidth = (main.offsetWidth + firewall.offsetWidth) / 1.1;
1490
+ if ( window.innerWidth < minWidth ) {
1491
+ dom.cl.add(dom.root, 'portrait');
1492
+ }
1493
+ };
1494
+
1465
1495
  // The purpose of the following code is to reset to a vertical layout
1466
1496
  // should the viewport not be enough wide to accommodate the horizontal
1467
1497
  // layout.
@@ -1474,24 +1504,7 @@ const getPopupData = async function(tabId, first = false) {
1474
1504
  // Use a tolerance proportional to the sum of the width of the panes
1475
1505
  // when testing against viewport width.
1476
1506
  const checkViewport = async function() {
1477
- if (
1478
- dom.cl.has(dom.root, 'mobile') ||
1479
- selfURL.searchParams.get('portrait')
1480
- ) {
1481
- dom.cl.add(dom.root, 'portrait');
1482
- dom.cl.remove(dom.root, 'desktop');
1483
- } else if ( dom.cl.has(dom.root, 'desktop') ) {
1484
- await nextFrames(8);
1485
- const main = qs$('#main');
1486
- const firewall = qs$('#firewall');
1487
- const minWidth = (main.offsetWidth + firewall.offsetWidth) / 1.1;
1488
- if (
1489
- selfURL.searchParams.get('portrait') ||
1490
- window.innerWidth < minWidth
1491
- ) {
1492
- dom.cl.add(dom.root, 'portrait');
1493
- }
1494
- }
1507
+ await setOrientation();
1495
1508
  if ( dom.cl.has(dom.root, 'portrait') ) {
1496
1509
  const panes = qs$('#panes');
1497
1510
  const sticky = qs$('#sticky');
@@ -24,11 +24,7 @@
24
24
  /******************************************************************************/
25
25
 
26
26
  import redirectableResources from './redirect-resources.js';
27
-
28
- import {
29
- LineIterator,
30
- orphanizeString,
31
- } from './text-utils.js';
27
+ import { LineIterator, orphanizeString } from './text-utils.js';
32
28
 
33
29
  /******************************************************************************/
34
30
 
@@ -76,7 +72,7 @@ const warSecret = typeof vAPI === 'object' && vAPI !== null
76
72
  : ( ) => '';
77
73
 
78
74
  const RESOURCES_SELFIE_VERSION = 7;
79
- const RESOURCES_SELFIE_NAME = 'compiled/redirectEngine/resources';
75
+ const RESOURCES_SELFIE_NAME = 'selfie/redirectEngine/resources';
80
76
 
81
77
  /******************************************************************************/
82
78
  /******************************************************************************/
@@ -448,33 +444,22 @@ class RedirectEngine {
448
444
  }
449
445
 
450
446
  selfieFromResources(storage) {
451
- storage.put(
452
- RESOURCES_SELFIE_NAME,
453
- JSON.stringify({
454
- version: RESOURCES_SELFIE_VERSION,
455
- aliases: Array.from(this.aliases),
456
- resources: Array.from(this.resources),
457
- })
458
- );
447
+ return storage.toCache(RESOURCES_SELFIE_NAME, {
448
+ version: RESOURCES_SELFIE_VERSION,
449
+ aliases: this.aliases,
450
+ resources: this.resources,
451
+ });
459
452
  }
460
453
 
461
454
  async resourcesFromSelfie(storage) {
462
- const result = await storage.get(RESOURCES_SELFIE_NAME);
463
- let selfie;
464
- try {
465
- selfie = JSON.parse(result.content);
466
- } catch(ex) {
467
- }
468
- if (
469
- selfie instanceof Object === false ||
470
- selfie.version !== RESOURCES_SELFIE_VERSION ||
471
- Array.isArray(selfie.resources) === false
472
- ) {
473
- return false;
474
- }
475
- this.aliases = new Map(selfie.aliases);
476
- this.resources = new Map();
477
- for ( const [ token, entry ] of selfie.resources ) {
455
+ const selfie = await storage.fromCache(RESOURCES_SELFIE_NAME);
456
+ if ( selfie instanceof Object === false ) { return false; }
457
+ if ( selfie.version !== RESOURCES_SELFIE_VERSION ) { return false; }
458
+ if ( selfie.aliases instanceof Map === false ) { return false; }
459
+ if ( selfie.resources instanceof Map === false ) { return false; }
460
+ this.aliases = selfie.aliases;
461
+ this.resources = selfie.resources;
462
+ for ( const [ token, entry ] of this.resources ) {
478
463
  this.resources.set(token, RedirectEntry.fromDetails(entry));
479
464
  }
480
465
  return true;
@@ -62,7 +62,7 @@ const stopWorker = function() {
62
62
  };
63
63
 
64
64
  const workerTTLTimer = vAPI.defer.create(stopWorker);
65
- const workerTTL = { min: 5 };
65
+ const workerTTL = { min: 1.5 };
66
66
 
67
67
  const initWorker = function() {
68
68
  if ( worker === null ) {