@browserless.io/browserless 2.0.0-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (875) hide show
  1. package/CHANGELOG.md +674 -0
  2. package/LICENSE +6 -0
  3. package/README.md +132 -0
  4. package/assets/logo.png +0 -0
  5. package/bin/browserless.js +227 -0
  6. package/browser.json +7 -0
  7. package/build/browserless.d.ts +33 -0
  8. package/build/browserless.js +146 -0
  9. package/build/browsers/cdp-chromium.d.ts +41 -0
  10. package/build/browsers/cdp-chromium.js +287 -0
  11. package/build/browsers/index.d.ts +26 -0
  12. package/build/browsers/index.js +183 -0
  13. package/build/browsers/playwright-chromium.d.ts +34 -0
  14. package/build/browsers/playwright-chromium.js +106 -0
  15. package/build/browsers/playwright-firefox.d.ts +34 -0
  16. package/build/browsers/playwright-firefox.js +101 -0
  17. package/build/browsers/playwright-webkit.d.ts +34 -0
  18. package/build/browsers/playwright-webkit.js +101 -0
  19. package/build/config.d.ts +138 -0
  20. package/build/config.js +349 -0
  21. package/build/constants.d.ts +4 -0
  22. package/build/constants.js +4 -0
  23. package/build/data/classes.json +1 -0
  24. package/build/data/selectors.json +1 -0
  25. package/build/exports.d.ts +20 -0
  26. package/build/exports.js +22 -0
  27. package/build/file-system.d.ts +24 -0
  28. package/build/file-system.js +46 -0
  29. package/build/hooks.d.ts +5 -0
  30. package/build/hooks.js +20 -0
  31. package/build/http.d.ts +175 -0
  32. package/build/http.js +104 -0
  33. package/build/index.d.ts +1 -0
  34. package/build/index.js +39 -0
  35. package/build/limiter.d.ts +24 -0
  36. package/build/limiter.js +147 -0
  37. package/build/limiter.spec.d.ts +1 -0
  38. package/build/limiter.spec.js +241 -0
  39. package/build/metrics.d.ts +24 -0
  40. package/build/metrics.js +86 -0
  41. package/build/metrics.spec.d.ts +1 -0
  42. package/build/metrics.spec.js +35 -0
  43. package/build/mime-types.d.ts +1 -0
  44. package/build/mime-types.js +328 -0
  45. package/build/monitoring.d.ts +13 -0
  46. package/build/monitoring.js +38 -0
  47. package/build/routes/chromium/http/content-post.body.json +514 -0
  48. package/build/routes/chromium/http/content-post.d.ts +34 -0
  49. package/build/routes/chromium/http/content-post.js +109 -0
  50. package/build/routes/chromium/http/content-post.query.json +183 -0
  51. package/build/routes/chromium/http/content-post.response.json +5 -0
  52. package/build/routes/chromium/http/download-post.body.json +32 -0
  53. package/build/routes/chromium/http/download-post.d.ts +16 -0
  54. package/build/routes/chromium/http/download-post.js +92 -0
  55. package/build/routes/chromium/http/download-post.query.json +120 -0
  56. package/build/routes/chromium/http/download-post.response.json +4 -0
  57. package/build/routes/chromium/http/function-post.body.json +32 -0
  58. package/build/routes/chromium/http/function-post.d.ts +18 -0
  59. package/build/routes/chromium/http/function-post.js +53 -0
  60. package/build/routes/chromium/http/function-post.query.json +120 -0
  61. package/build/routes/chromium/http/function-post.response.json +4 -0
  62. package/build/routes/chromium/http/pdf-post.body.json +654 -0
  63. package/build/routes/chromium/http/pdf-post.d.ts +35 -0
  64. package/build/routes/chromium/http/pdf-post.js +107 -0
  65. package/build/routes/chromium/http/pdf-post.query.json +120 -0
  66. package/build/routes/chromium/http/pdf-post.response.json +5 -0
  67. package/build/routes/chromium/http/performance.body.json +26 -0
  68. package/build/routes/chromium/http/performance.d.ts +17 -0
  69. package/build/routes/chromium/http/performance.js +30 -0
  70. package/build/routes/chromium/http/performance.query.json +120 -0
  71. package/build/routes/chromium/http/performance.response.json +7 -0
  72. package/build/routes/chromium/http/scrape-post.body.json +561 -0
  73. package/build/routes/chromium/http/scrape-post.d.ts +106 -0
  74. package/build/routes/chromium/http/scrape-post.js +205 -0
  75. package/build/routes/chromium/http/scrape-post.query.json +183 -0
  76. package/build/routes/chromium/http/scrape-post.response.json +325 -0
  77. package/build/routes/chromium/http/screenshot-post.body.json +604 -0
  78. package/build/routes/chromium/http/screenshot-post.d.ts +37 -0
  79. package/build/routes/chromium/http/screenshot-post.js +124 -0
  80. package/build/routes/chromium/http/screenshot-post.query.json +120 -0
  81. package/build/routes/chromium/http/screenshot-post.response.json +5 -0
  82. package/build/routes/chromium/tests/content.spec.d.ts +1 -0
  83. package/build/routes/chromium/tests/content.spec.js +285 -0
  84. package/build/routes/chromium/tests/download.spec.d.ts +1 -0
  85. package/build/routes/chromium/tests/download.spec.js +67 -0
  86. package/build/routes/chromium/tests/function.spec.d.ts +1 -0
  87. package/build/routes/chromium/tests/function.spec.js +245 -0
  88. package/build/routes/chromium/tests/pdf.spec.d.ts +1 -0
  89. package/build/routes/chromium/tests/pdf.spec.js +333 -0
  90. package/build/routes/chromium/tests/performance.spec.d.ts +1 -0
  91. package/build/routes/chromium/tests/performance.spec.js +124 -0
  92. package/build/routes/chromium/tests/scrape.spec.d.ts +1 -0
  93. package/build/routes/chromium/tests/scrape.spec.js +354 -0
  94. package/build/routes/chromium/tests/screenshot.spec.d.ts +1 -0
  95. package/build/routes/chromium/tests/screenshot.spec.js +339 -0
  96. package/build/routes/chromium/tests/websocket.spec.d.ts +1 -0
  97. package/build/routes/chromium/tests/websocket.spec.js +309 -0
  98. package/build/routes/chromium/utils/function/client.d.ts +26 -0
  99. package/build/routes/chromium/utils/function/client.js +66 -0
  100. package/build/routes/chromium/utils/function/handler.d.ts +18 -0
  101. package/build/routes/chromium/utils/function/handler.js +95 -0
  102. package/build/routes/chromium/utils/performance/child.d.ts +1 -0
  103. package/build/routes/chromium/utils/performance/child.js +29 -0
  104. package/build/routes/chromium/utils/performance/main.d.ts +3 -0
  105. package/build/routes/chromium/utils/performance/main.js +65 -0
  106. package/build/routes/chromium/utils/performance/types.d.ts +21 -0
  107. package/build/routes/chromium/utils/performance/types.js +1 -0
  108. package/build/routes/chromium/ws/browser.d.ts +6 -0
  109. package/build/routes/chromium/ws/browser.js +11 -0
  110. package/build/routes/chromium/ws/browser.query.json +120 -0
  111. package/build/routes/chromium/ws/cdp-chromium.d.ts +6 -0
  112. package/build/routes/chromium/ws/cdp-chromium.js +11 -0
  113. package/build/routes/chromium/ws/cdp-chromium.query.json +120 -0
  114. package/build/routes/chromium/ws/page.d.ts +6 -0
  115. package/build/routes/chromium/ws/page.js +11 -0
  116. package/build/routes/chromium/ws/page.query.json +120 -0
  117. package/build/routes/chromium/ws/playwright-chromium.d.ts +6 -0
  118. package/build/routes/chromium/ws/playwright-chromium.js +19 -0
  119. package/build/routes/chromium/ws/playwright-chromium.query.json +100 -0
  120. package/build/routes/firefox/tests/websocket.spec.d.ts +1 -0
  121. package/build/routes/firefox/tests/websocket.spec.js +104 -0
  122. package/build/routes/firefox/ws/playwright-firefox.d.ts +6 -0
  123. package/build/routes/firefox/ws/playwright-firefox.js +19 -0
  124. package/build/routes/firefox/ws/playwright-firefox.query.json +100 -0
  125. package/build/routes/management/http/config-get.d.ts +25 -0
  126. package/build/routes/management/http/config-get.js +43 -0
  127. package/build/routes/management/http/config-get.response.json +107 -0
  128. package/build/routes/management/http/metrics-get.d.ts +4 -0
  129. package/build/routes/management/http/metrics-get.js +24 -0
  130. package/build/routes/management/http/metrics-get.response.json +94 -0
  131. package/build/routes/management/http/metrics-total-get.d.ts +4 -0
  132. package/build/routes/management/http/metrics-total-get.js +60 -0
  133. package/build/routes/management/http/metrics-total-get.response.json +72 -0
  134. package/build/routes/management/http/sessions-get.d.ts +4 -0
  135. package/build/routes/management/http/sessions-get.js +21 -0
  136. package/build/routes/management/http/sessions-get.response.json +221 -0
  137. package/build/routes/management/http/static-get.d.ts +3 -0
  138. package/build/routes/management/http/static-get.js +67 -0
  139. package/build/routes/management/tests/management.spec.d.ts +1 -0
  140. package/build/routes/management/tests/management.spec.js +41 -0
  141. package/build/routes/webkit/tests/websocket.spec.d.ts +1 -0
  142. package/build/routes/webkit/tests/websocket.spec.js +104 -0
  143. package/build/routes/webkit/ws/playwright-webkit.d.ts +6 -0
  144. package/build/routes/webkit/ws/playwright-webkit.js +19 -0
  145. package/build/routes/webkit/ws/playwright-webkit.query.json +100 -0
  146. package/build/server.d.ts +38 -0
  147. package/build/server.js +365 -0
  148. package/build/shim.d.ts +9 -0
  149. package/build/shim.js +54 -0
  150. package/build/shim.spec.d.ts +1 -0
  151. package/build/shim.spec.js +114 -0
  152. package/build/types.d.ts +360 -0
  153. package/build/types.js +6 -0
  154. package/build/utils.d.ts +111 -0
  155. package/build/utils.js +570 -0
  156. package/build/webhooks.d.ts +11 -0
  157. package/build/webhooks.js +43 -0
  158. package/docker/base/.dockerignore +16 -0
  159. package/docker/base/Dockerfile +70 -0
  160. package/docker/chrome/.dockerignore +16 -0
  161. package/docker/chrome/Dockerfile +40 -0
  162. package/docker/firefox/.dockerignore +16 -0
  163. package/docker/firefox/Dockerfile +39 -0
  164. package/docker/multi/.dockerignore +16 -0
  165. package/docker/multi/Dockerfile +37 -0
  166. package/docker/sdk/.dockerignore +16 -0
  167. package/docker/sdk/Dockerfile +34 -0
  168. package/docker/webkit/.dockerignore +16 -0
  169. package/docker/webkit/Dockerfile +40 -0
  170. package/extensions/screencast/background.js +143 -0
  171. package/extensions/screencast/content_script.js +18 -0
  172. package/extensions/screencast/manifest.json +19 -0
  173. package/extensions/ublock/1p-filters.html +69 -0
  174. package/extensions/ublock/3p-filters.html +119 -0
  175. package/extensions/ublock/LICENSE.txt +674 -0
  176. package/extensions/ublock/_locales/ar/messages.json +1290 -0
  177. package/extensions/ublock/_locales/az/messages.json +1290 -0
  178. package/extensions/ublock/_locales/be/messages.json +1290 -0
  179. package/extensions/ublock/_locales/bg/messages.json +1290 -0
  180. package/extensions/ublock/_locales/bn/messages.json +1290 -0
  181. package/extensions/ublock/_locales/br_FR/messages.json +1290 -0
  182. package/extensions/ublock/_locales/bs/messages.json +1290 -0
  183. package/extensions/ublock/_locales/ca/messages.json +1290 -0
  184. package/extensions/ublock/_locales/cs/messages.json +1290 -0
  185. package/extensions/ublock/_locales/cv/messages.json +1290 -0
  186. package/extensions/ublock/_locales/da/messages.json +1290 -0
  187. package/extensions/ublock/_locales/de/messages.json +1290 -0
  188. package/extensions/ublock/_locales/el/messages.json +1290 -0
  189. package/extensions/ublock/_locales/en/messages.json +1292 -0
  190. package/extensions/ublock/_locales/en_GB/messages.json +1290 -0
  191. package/extensions/ublock/_locales/eo/messages.json +1290 -0
  192. package/extensions/ublock/_locales/es/messages.json +1290 -0
  193. package/extensions/ublock/_locales/et/messages.json +1290 -0
  194. package/extensions/ublock/_locales/eu/messages.json +1290 -0
  195. package/extensions/ublock/_locales/fa/messages.json +1290 -0
  196. package/extensions/ublock/_locales/fi/messages.json +1290 -0
  197. package/extensions/ublock/_locales/fil/messages.json +1290 -0
  198. package/extensions/ublock/_locales/fr/messages.json +1290 -0
  199. package/extensions/ublock/_locales/fy/messages.json +1290 -0
  200. package/extensions/ublock/_locales/gl/messages.json +1290 -0
  201. package/extensions/ublock/_locales/gu/messages.json +1290 -0
  202. package/extensions/ublock/_locales/he/messages.json +1290 -0
  203. package/extensions/ublock/_locales/hi/messages.json +1290 -0
  204. package/extensions/ublock/_locales/hr/messages.json +1290 -0
  205. package/extensions/ublock/_locales/hu/messages.json +1290 -0
  206. package/extensions/ublock/_locales/hy/messages.json +1290 -0
  207. package/extensions/ublock/_locales/id/messages.json +1290 -0
  208. package/extensions/ublock/_locales/it/messages.json +1290 -0
  209. package/extensions/ublock/_locales/ja/messages.json +1290 -0
  210. package/extensions/ublock/_locales/ka/messages.json +1290 -0
  211. package/extensions/ublock/_locales/kk/messages.json +1290 -0
  212. package/extensions/ublock/_locales/kn/messages.json +1290 -0
  213. package/extensions/ublock/_locales/ko/messages.json +1290 -0
  214. package/extensions/ublock/_locales/ku/messages.json +1290 -0
  215. package/extensions/ublock/_locales/lt/messages.json +1290 -0
  216. package/extensions/ublock/_locales/lv/messages.json +1290 -0
  217. package/extensions/ublock/_locales/mk/messages.json +1290 -0
  218. package/extensions/ublock/_locales/ml/messages.json +1290 -0
  219. package/extensions/ublock/_locales/mr/messages.json +1290 -0
  220. package/extensions/ublock/_locales/ms/messages.json +1290 -0
  221. package/extensions/ublock/_locales/nb/messages.json +1290 -0
  222. package/extensions/ublock/_locales/nl/messages.json +1290 -0
  223. package/extensions/ublock/_locales/no/messages.json +1290 -0
  224. package/extensions/ublock/_locales/oc/messages.json +1290 -0
  225. package/extensions/ublock/_locales/pa/messages.json +1290 -0
  226. package/extensions/ublock/_locales/pl/messages.json +1290 -0
  227. package/extensions/ublock/_locales/pt_BR/messages.json +1290 -0
  228. package/extensions/ublock/_locales/pt_PT/messages.json +1290 -0
  229. package/extensions/ublock/_locales/ro/messages.json +1290 -0
  230. package/extensions/ublock/_locales/ru/messages.json +1290 -0
  231. package/extensions/ublock/_locales/si/messages.json +1290 -0
  232. package/extensions/ublock/_locales/sk/messages.json +1290 -0
  233. package/extensions/ublock/_locales/sl/messages.json +1290 -0
  234. package/extensions/ublock/_locales/so/messages.json +1290 -0
  235. package/extensions/ublock/_locales/sq/messages.json +1290 -0
  236. package/extensions/ublock/_locales/sr/messages.json +1290 -0
  237. package/extensions/ublock/_locales/sv/messages.json +1290 -0
  238. package/extensions/ublock/_locales/sw/messages.json +1290 -0
  239. package/extensions/ublock/_locales/ta/messages.json +1290 -0
  240. package/extensions/ublock/_locales/te/messages.json +1290 -0
  241. package/extensions/ublock/_locales/th/messages.json +1290 -0
  242. package/extensions/ublock/_locales/tr/messages.json +1290 -0
  243. package/extensions/ublock/_locales/uk/messages.json +1290 -0
  244. package/extensions/ublock/_locales/ur/messages.json +1290 -0
  245. package/extensions/ublock/_locales/vi/messages.json +1290 -0
  246. package/extensions/ublock/_locales/zh_CN/messages.json +1290 -0
  247. package/extensions/ublock/_locales/zh_TW/messages.json +1290 -0
  248. package/extensions/ublock/about.html +63 -0
  249. package/extensions/ublock/advanced-settings.html +42 -0
  250. package/extensions/ublock/asset-viewer.html +50 -0
  251. package/extensions/ublock/assets/assets.json +903 -0
  252. package/extensions/ublock/assets/resources/scriptlets.js +4255 -0
  253. package/extensions/ublock/assets/thirdparties/easylist/easylist.txt +65576 -0
  254. package/extensions/ublock/assets/thirdparties/easylist/easyprivacy.txt +33219 -0
  255. package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/README.md +29 -0
  256. package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/serverlist +3732 -0
  257. package/extensions/ublock/assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat +15431 -0
  258. package/extensions/ublock/assets/thirdparties/urlhaus-filter/LICENSE.md +42 -0
  259. package/extensions/ublock/assets/thirdparties/urlhaus-filter/urlhaus-filter-online.txt +1970 -0
  260. package/extensions/ublock/assets/ublock/badlists.txt +77 -0
  261. package/extensions/ublock/assets/ublock/badware.min.txt +3033 -0
  262. package/extensions/ublock/assets/ublock/filters.min.txt +23419 -0
  263. package/extensions/ublock/assets/ublock/privacy.min.txt +575 -0
  264. package/extensions/ublock/assets/ublock/quick-fixes.min.txt +99 -0
  265. package/extensions/ublock/assets/ublock/unbreak.min.txt +2448 -0
  266. package/extensions/ublock/background.html +12 -0
  267. package/extensions/ublock/cloud-ui.html +23 -0
  268. package/extensions/ublock/code-viewer.html +53 -0
  269. package/extensions/ublock/css/1p-filters.css +26 -0
  270. package/extensions/ublock/css/3p-filters.css +250 -0
  271. package/extensions/ublock/css/about.css +3 -0
  272. package/extensions/ublock/css/advanced-settings.css +26 -0
  273. package/extensions/ublock/css/asset-viewer.css +79 -0
  274. package/extensions/ublock/css/click2load.css +53 -0
  275. package/extensions/ublock/css/cloud-ui.css +104 -0
  276. package/extensions/ublock/css/code-viewer.css +67 -0
  277. package/extensions/ublock/css/codemirror.css +326 -0
  278. package/extensions/ublock/css/common.css +347 -0
  279. package/extensions/ublock/css/dashboard-common.css +55 -0
  280. package/extensions/ublock/css/dashboard.css +115 -0
  281. package/extensions/ublock/css/devtools.css +22 -0
  282. package/extensions/ublock/css/document-blocked.css +146 -0
  283. package/extensions/ublock/css/dyna-rules.css +79 -0
  284. package/extensions/ublock/css/epicker-ui.css +270 -0
  285. package/extensions/ublock/css/fa-icons.css +149 -0
  286. package/extensions/ublock/css/fonts/Inter/Inter-Regular.woff2 +0 -0
  287. package/extensions/ublock/css/fonts/Inter/Inter-SemiBold.woff2 +0 -0
  288. package/extensions/ublock/css/fonts/Inter/LICENSE.txt +93 -0
  289. package/extensions/ublock/css/fonts/Metropolis/Metropolis-Regular.woff2 +0 -0
  290. package/extensions/ublock/css/fonts/Metropolis/Metropolis-SemiBold.woff2 +0 -0
  291. package/extensions/ublock/css/fonts/Metropolis/README.md +25 -0
  292. package/extensions/ublock/css/fonts/Metropolis/UNLICENSE +24 -0
  293. package/extensions/ublock/css/logger-ui-inspector.css +116 -0
  294. package/extensions/ublock/css/logger-ui.css +978 -0
  295. package/extensions/ublock/css/popup-fenix.css +778 -0
  296. package/extensions/ublock/css/settings.css +74 -0
  297. package/extensions/ublock/css/support.css +110 -0
  298. package/extensions/ublock/css/themes/default.css +526 -0
  299. package/extensions/ublock/css/whitelist.css +22 -0
  300. package/extensions/ublock/dashboard.html +47 -0
  301. package/extensions/ublock/devtools.html +58 -0
  302. package/extensions/ublock/document-blocked.html +64 -0
  303. package/extensions/ublock/dyna-rules.html +67 -0
  304. package/extensions/ublock/img/cloud.png +0 -0
  305. package/extensions/ublock/img/flags-of-the-world/README +9 -0
  306. package/extensions/ublock/img/flags-of-the-world/ad.png +0 -0
  307. package/extensions/ublock/img/flags-of-the-world/ae.png +0 -0
  308. package/extensions/ublock/img/flags-of-the-world/af.png +0 -0
  309. package/extensions/ublock/img/flags-of-the-world/ag.png +0 -0
  310. package/extensions/ublock/img/flags-of-the-world/ai.png +0 -0
  311. package/extensions/ublock/img/flags-of-the-world/al.png +0 -0
  312. package/extensions/ublock/img/flags-of-the-world/am.png +0 -0
  313. package/extensions/ublock/img/flags-of-the-world/ao.png +0 -0
  314. package/extensions/ublock/img/flags-of-the-world/aq.png +0 -0
  315. package/extensions/ublock/img/flags-of-the-world/ar.png +0 -0
  316. package/extensions/ublock/img/flags-of-the-world/as.png +0 -0
  317. package/extensions/ublock/img/flags-of-the-world/at.png +0 -0
  318. package/extensions/ublock/img/flags-of-the-world/au.png +0 -0
  319. package/extensions/ublock/img/flags-of-the-world/aw.png +0 -0
  320. package/extensions/ublock/img/flags-of-the-world/ax.png +0 -0
  321. package/extensions/ublock/img/flags-of-the-world/az.png +0 -0
  322. package/extensions/ublock/img/flags-of-the-world/ba.png +0 -0
  323. package/extensions/ublock/img/flags-of-the-world/bb.png +0 -0
  324. package/extensions/ublock/img/flags-of-the-world/bd.png +0 -0
  325. package/extensions/ublock/img/flags-of-the-world/be.png +0 -0
  326. package/extensions/ublock/img/flags-of-the-world/bf.png +0 -0
  327. package/extensions/ublock/img/flags-of-the-world/bg.png +0 -0
  328. package/extensions/ublock/img/flags-of-the-world/bh.png +0 -0
  329. package/extensions/ublock/img/flags-of-the-world/bi.png +0 -0
  330. package/extensions/ublock/img/flags-of-the-world/bj.png +0 -0
  331. package/extensions/ublock/img/flags-of-the-world/bl.png +0 -0
  332. package/extensions/ublock/img/flags-of-the-world/bm.png +0 -0
  333. package/extensions/ublock/img/flags-of-the-world/bn.png +0 -0
  334. package/extensions/ublock/img/flags-of-the-world/bo.png +0 -0
  335. package/extensions/ublock/img/flags-of-the-world/bq.png +0 -0
  336. package/extensions/ublock/img/flags-of-the-world/br.png +0 -0
  337. package/extensions/ublock/img/flags-of-the-world/bs.png +0 -0
  338. package/extensions/ublock/img/flags-of-the-world/bt.png +0 -0
  339. package/extensions/ublock/img/flags-of-the-world/bv.png +0 -0
  340. package/extensions/ublock/img/flags-of-the-world/bw.png +0 -0
  341. package/extensions/ublock/img/flags-of-the-world/by.png +0 -0
  342. package/extensions/ublock/img/flags-of-the-world/bz.png +0 -0
  343. package/extensions/ublock/img/flags-of-the-world/ca.png +0 -0
  344. package/extensions/ublock/img/flags-of-the-world/cc.png +0 -0
  345. package/extensions/ublock/img/flags-of-the-world/cd.png +0 -0
  346. package/extensions/ublock/img/flags-of-the-world/cf.png +0 -0
  347. package/extensions/ublock/img/flags-of-the-world/cg.png +0 -0
  348. package/extensions/ublock/img/flags-of-the-world/ch.png +0 -0
  349. package/extensions/ublock/img/flags-of-the-world/ci.png +0 -0
  350. package/extensions/ublock/img/flags-of-the-world/ck.png +0 -0
  351. package/extensions/ublock/img/flags-of-the-world/cl.png +0 -0
  352. package/extensions/ublock/img/flags-of-the-world/cm.png +0 -0
  353. package/extensions/ublock/img/flags-of-the-world/cn.png +0 -0
  354. package/extensions/ublock/img/flags-of-the-world/co.png +0 -0
  355. package/extensions/ublock/img/flags-of-the-world/cr.png +0 -0
  356. package/extensions/ublock/img/flags-of-the-world/cu.png +0 -0
  357. package/extensions/ublock/img/flags-of-the-world/cv.png +0 -0
  358. package/extensions/ublock/img/flags-of-the-world/cw.png +0 -0
  359. package/extensions/ublock/img/flags-of-the-world/cx.png +0 -0
  360. package/extensions/ublock/img/flags-of-the-world/cy.png +0 -0
  361. package/extensions/ublock/img/flags-of-the-world/cz.png +0 -0
  362. package/extensions/ublock/img/flags-of-the-world/de.png +0 -0
  363. package/extensions/ublock/img/flags-of-the-world/dj.png +0 -0
  364. package/extensions/ublock/img/flags-of-the-world/dk.png +0 -0
  365. package/extensions/ublock/img/flags-of-the-world/dm.png +0 -0
  366. package/extensions/ublock/img/flags-of-the-world/do.png +0 -0
  367. package/extensions/ublock/img/flags-of-the-world/dz.png +0 -0
  368. package/extensions/ublock/img/flags-of-the-world/ec.png +0 -0
  369. package/extensions/ublock/img/flags-of-the-world/ee.png +0 -0
  370. package/extensions/ublock/img/flags-of-the-world/eg.png +0 -0
  371. package/extensions/ublock/img/flags-of-the-world/eh.png +0 -0
  372. package/extensions/ublock/img/flags-of-the-world/er.png +0 -0
  373. package/extensions/ublock/img/flags-of-the-world/es.png +0 -0
  374. package/extensions/ublock/img/flags-of-the-world/et.png +0 -0
  375. package/extensions/ublock/img/flags-of-the-world/fi.png +0 -0
  376. package/extensions/ublock/img/flags-of-the-world/fj.png +0 -0
  377. package/extensions/ublock/img/flags-of-the-world/fk.png +0 -0
  378. package/extensions/ublock/img/flags-of-the-world/fm.png +0 -0
  379. package/extensions/ublock/img/flags-of-the-world/fo.png +0 -0
  380. package/extensions/ublock/img/flags-of-the-world/fr.png +0 -0
  381. package/extensions/ublock/img/flags-of-the-world/ga.png +0 -0
  382. package/extensions/ublock/img/flags-of-the-world/gb-eng.png +0 -0
  383. package/extensions/ublock/img/flags-of-the-world/gb-nir.png +0 -0
  384. package/extensions/ublock/img/flags-of-the-world/gb-sct.png +0 -0
  385. package/extensions/ublock/img/flags-of-the-world/gb-wls.png +0 -0
  386. package/extensions/ublock/img/flags-of-the-world/gb.png +0 -0
  387. package/extensions/ublock/img/flags-of-the-world/gd.png +0 -0
  388. package/extensions/ublock/img/flags-of-the-world/ge.png +0 -0
  389. package/extensions/ublock/img/flags-of-the-world/gf.png +0 -0
  390. package/extensions/ublock/img/flags-of-the-world/gg.png +0 -0
  391. package/extensions/ublock/img/flags-of-the-world/gh.png +0 -0
  392. package/extensions/ublock/img/flags-of-the-world/gi.png +0 -0
  393. package/extensions/ublock/img/flags-of-the-world/gl.png +0 -0
  394. package/extensions/ublock/img/flags-of-the-world/gm.png +0 -0
  395. package/extensions/ublock/img/flags-of-the-world/gn.png +0 -0
  396. package/extensions/ublock/img/flags-of-the-world/gp.png +0 -0
  397. package/extensions/ublock/img/flags-of-the-world/gq.png +0 -0
  398. package/extensions/ublock/img/flags-of-the-world/gr.png +0 -0
  399. package/extensions/ublock/img/flags-of-the-world/gs.png +0 -0
  400. package/extensions/ublock/img/flags-of-the-world/gt.png +0 -0
  401. package/extensions/ublock/img/flags-of-the-world/gu.png +0 -0
  402. package/extensions/ublock/img/flags-of-the-world/gw.png +0 -0
  403. package/extensions/ublock/img/flags-of-the-world/gy.png +0 -0
  404. package/extensions/ublock/img/flags-of-the-world/hk.png +0 -0
  405. package/extensions/ublock/img/flags-of-the-world/hm.png +0 -0
  406. package/extensions/ublock/img/flags-of-the-world/hn.png +0 -0
  407. package/extensions/ublock/img/flags-of-the-world/hr.png +0 -0
  408. package/extensions/ublock/img/flags-of-the-world/ht.png +0 -0
  409. package/extensions/ublock/img/flags-of-the-world/hu.png +0 -0
  410. package/extensions/ublock/img/flags-of-the-world/id.png +0 -0
  411. package/extensions/ublock/img/flags-of-the-world/ie.png +0 -0
  412. package/extensions/ublock/img/flags-of-the-world/il.png +0 -0
  413. package/extensions/ublock/img/flags-of-the-world/im.png +0 -0
  414. package/extensions/ublock/img/flags-of-the-world/in.png +0 -0
  415. package/extensions/ublock/img/flags-of-the-world/io.png +0 -0
  416. package/extensions/ublock/img/flags-of-the-world/iq.png +0 -0
  417. package/extensions/ublock/img/flags-of-the-world/ir.png +0 -0
  418. package/extensions/ublock/img/flags-of-the-world/is.png +0 -0
  419. package/extensions/ublock/img/flags-of-the-world/it.png +0 -0
  420. package/extensions/ublock/img/flags-of-the-world/je.png +0 -0
  421. package/extensions/ublock/img/flags-of-the-world/jm.png +0 -0
  422. package/extensions/ublock/img/flags-of-the-world/jo.png +0 -0
  423. package/extensions/ublock/img/flags-of-the-world/jp.png +0 -0
  424. package/extensions/ublock/img/flags-of-the-world/ke.png +0 -0
  425. package/extensions/ublock/img/flags-of-the-world/kg.png +0 -0
  426. package/extensions/ublock/img/flags-of-the-world/kh.png +0 -0
  427. package/extensions/ublock/img/flags-of-the-world/ki.png +0 -0
  428. package/extensions/ublock/img/flags-of-the-world/km.png +0 -0
  429. package/extensions/ublock/img/flags-of-the-world/kn.png +0 -0
  430. package/extensions/ublock/img/flags-of-the-world/kp.png +0 -0
  431. package/extensions/ublock/img/flags-of-the-world/kr.png +0 -0
  432. package/extensions/ublock/img/flags-of-the-world/kw.png +0 -0
  433. package/extensions/ublock/img/flags-of-the-world/ky.png +0 -0
  434. package/extensions/ublock/img/flags-of-the-world/kz.png +0 -0
  435. package/extensions/ublock/img/flags-of-the-world/la.png +0 -0
  436. package/extensions/ublock/img/flags-of-the-world/lb.png +0 -0
  437. package/extensions/ublock/img/flags-of-the-world/lc.png +0 -0
  438. package/extensions/ublock/img/flags-of-the-world/li.png +0 -0
  439. package/extensions/ublock/img/flags-of-the-world/lk.png +0 -0
  440. package/extensions/ublock/img/flags-of-the-world/lr.png +0 -0
  441. package/extensions/ublock/img/flags-of-the-world/ls.png +0 -0
  442. package/extensions/ublock/img/flags-of-the-world/lt.png +0 -0
  443. package/extensions/ublock/img/flags-of-the-world/lu.png +0 -0
  444. package/extensions/ublock/img/flags-of-the-world/lv.png +0 -0
  445. package/extensions/ublock/img/flags-of-the-world/ly.png +0 -0
  446. package/extensions/ublock/img/flags-of-the-world/ma.png +0 -0
  447. package/extensions/ublock/img/flags-of-the-world/mc.png +0 -0
  448. package/extensions/ublock/img/flags-of-the-world/md.png +0 -0
  449. package/extensions/ublock/img/flags-of-the-world/me.png +0 -0
  450. package/extensions/ublock/img/flags-of-the-world/mf.png +0 -0
  451. package/extensions/ublock/img/flags-of-the-world/mg.png +0 -0
  452. package/extensions/ublock/img/flags-of-the-world/mh.png +0 -0
  453. package/extensions/ublock/img/flags-of-the-world/mk.png +0 -0
  454. package/extensions/ublock/img/flags-of-the-world/ml.png +0 -0
  455. package/extensions/ublock/img/flags-of-the-world/mm.png +0 -0
  456. package/extensions/ublock/img/flags-of-the-world/mn.png +0 -0
  457. package/extensions/ublock/img/flags-of-the-world/mo.png +0 -0
  458. package/extensions/ublock/img/flags-of-the-world/mp.png +0 -0
  459. package/extensions/ublock/img/flags-of-the-world/mq.png +0 -0
  460. package/extensions/ublock/img/flags-of-the-world/mr.png +0 -0
  461. package/extensions/ublock/img/flags-of-the-world/ms.png +0 -0
  462. package/extensions/ublock/img/flags-of-the-world/mt.png +0 -0
  463. package/extensions/ublock/img/flags-of-the-world/mu.png +0 -0
  464. package/extensions/ublock/img/flags-of-the-world/mv.png +0 -0
  465. package/extensions/ublock/img/flags-of-the-world/mw.png +0 -0
  466. package/extensions/ublock/img/flags-of-the-world/mx.png +0 -0
  467. package/extensions/ublock/img/flags-of-the-world/my.png +0 -0
  468. package/extensions/ublock/img/flags-of-the-world/mz.png +0 -0
  469. package/extensions/ublock/img/flags-of-the-world/na.png +0 -0
  470. package/extensions/ublock/img/flags-of-the-world/nc.png +0 -0
  471. package/extensions/ublock/img/flags-of-the-world/ne.png +0 -0
  472. package/extensions/ublock/img/flags-of-the-world/nf.png +0 -0
  473. package/extensions/ublock/img/flags-of-the-world/ng.png +0 -0
  474. package/extensions/ublock/img/flags-of-the-world/ni.png +0 -0
  475. package/extensions/ublock/img/flags-of-the-world/nl.png +0 -0
  476. package/extensions/ublock/img/flags-of-the-world/no.png +0 -0
  477. package/extensions/ublock/img/flags-of-the-world/np.png +0 -0
  478. package/extensions/ublock/img/flags-of-the-world/nr.png +0 -0
  479. package/extensions/ublock/img/flags-of-the-world/nu.png +0 -0
  480. package/extensions/ublock/img/flags-of-the-world/nz.png +0 -0
  481. package/extensions/ublock/img/flags-of-the-world/om.png +0 -0
  482. package/extensions/ublock/img/flags-of-the-world/pa.png +0 -0
  483. package/extensions/ublock/img/flags-of-the-world/pe.png +0 -0
  484. package/extensions/ublock/img/flags-of-the-world/pf.png +0 -0
  485. package/extensions/ublock/img/flags-of-the-world/pg.png +0 -0
  486. package/extensions/ublock/img/flags-of-the-world/ph.png +0 -0
  487. package/extensions/ublock/img/flags-of-the-world/pk.png +0 -0
  488. package/extensions/ublock/img/flags-of-the-world/pl.png +0 -0
  489. package/extensions/ublock/img/flags-of-the-world/pm.png +0 -0
  490. package/extensions/ublock/img/flags-of-the-world/pn.png +0 -0
  491. package/extensions/ublock/img/flags-of-the-world/pr.png +0 -0
  492. package/extensions/ublock/img/flags-of-the-world/ps.png +0 -0
  493. package/extensions/ublock/img/flags-of-the-world/pt.png +0 -0
  494. package/extensions/ublock/img/flags-of-the-world/pw.png +0 -0
  495. package/extensions/ublock/img/flags-of-the-world/py.png +0 -0
  496. package/extensions/ublock/img/flags-of-the-world/qa.png +0 -0
  497. package/extensions/ublock/img/flags-of-the-world/re.png +0 -0
  498. package/extensions/ublock/img/flags-of-the-world/ro.png +0 -0
  499. package/extensions/ublock/img/flags-of-the-world/rs.png +0 -0
  500. package/extensions/ublock/img/flags-of-the-world/ru.png +0 -0
  501. package/extensions/ublock/img/flags-of-the-world/rw.png +0 -0
  502. package/extensions/ublock/img/flags-of-the-world/sa.png +0 -0
  503. package/extensions/ublock/img/flags-of-the-world/sb.png +0 -0
  504. package/extensions/ublock/img/flags-of-the-world/sc.png +0 -0
  505. package/extensions/ublock/img/flags-of-the-world/sd.png +0 -0
  506. package/extensions/ublock/img/flags-of-the-world/se.png +0 -0
  507. package/extensions/ublock/img/flags-of-the-world/sg.png +0 -0
  508. package/extensions/ublock/img/flags-of-the-world/sh.png +0 -0
  509. package/extensions/ublock/img/flags-of-the-world/si.png +0 -0
  510. package/extensions/ublock/img/flags-of-the-world/sj.png +0 -0
  511. package/extensions/ublock/img/flags-of-the-world/sk.png +0 -0
  512. package/extensions/ublock/img/flags-of-the-world/sl.png +0 -0
  513. package/extensions/ublock/img/flags-of-the-world/sm.png +0 -0
  514. package/extensions/ublock/img/flags-of-the-world/sn.png +0 -0
  515. package/extensions/ublock/img/flags-of-the-world/so.png +0 -0
  516. package/extensions/ublock/img/flags-of-the-world/sr.png +0 -0
  517. package/extensions/ublock/img/flags-of-the-world/ss.png +0 -0
  518. package/extensions/ublock/img/flags-of-the-world/st.png +0 -0
  519. package/extensions/ublock/img/flags-of-the-world/sv.png +0 -0
  520. package/extensions/ublock/img/flags-of-the-world/sx.png +0 -0
  521. package/extensions/ublock/img/flags-of-the-world/sy.png +0 -0
  522. package/extensions/ublock/img/flags-of-the-world/sz.png +0 -0
  523. package/extensions/ublock/img/flags-of-the-world/tc.png +0 -0
  524. package/extensions/ublock/img/flags-of-the-world/td.png +0 -0
  525. package/extensions/ublock/img/flags-of-the-world/tf.png +0 -0
  526. package/extensions/ublock/img/flags-of-the-world/tg.png +0 -0
  527. package/extensions/ublock/img/flags-of-the-world/th.png +0 -0
  528. package/extensions/ublock/img/flags-of-the-world/tj.png +0 -0
  529. package/extensions/ublock/img/flags-of-the-world/tk.png +0 -0
  530. package/extensions/ublock/img/flags-of-the-world/tl.png +0 -0
  531. package/extensions/ublock/img/flags-of-the-world/tm.png +0 -0
  532. package/extensions/ublock/img/flags-of-the-world/tn.png +0 -0
  533. package/extensions/ublock/img/flags-of-the-world/to.png +0 -0
  534. package/extensions/ublock/img/flags-of-the-world/tr.png +0 -0
  535. package/extensions/ublock/img/flags-of-the-world/tt.png +0 -0
  536. package/extensions/ublock/img/flags-of-the-world/tv.png +0 -0
  537. package/extensions/ublock/img/flags-of-the-world/tw.png +0 -0
  538. package/extensions/ublock/img/flags-of-the-world/tz.png +0 -0
  539. package/extensions/ublock/img/flags-of-the-world/ua.png +0 -0
  540. package/extensions/ublock/img/flags-of-the-world/ug.png +0 -0
  541. package/extensions/ublock/img/flags-of-the-world/um.png +0 -0
  542. package/extensions/ublock/img/flags-of-the-world/us.png +0 -0
  543. package/extensions/ublock/img/flags-of-the-world/uy.png +0 -0
  544. package/extensions/ublock/img/flags-of-the-world/uz.png +0 -0
  545. package/extensions/ublock/img/flags-of-the-world/va.png +0 -0
  546. package/extensions/ublock/img/flags-of-the-world/vc.png +0 -0
  547. package/extensions/ublock/img/flags-of-the-world/ve.png +0 -0
  548. package/extensions/ublock/img/flags-of-the-world/vg.png +0 -0
  549. package/extensions/ublock/img/flags-of-the-world/vi.png +0 -0
  550. package/extensions/ublock/img/flags-of-the-world/vn.png +0 -0
  551. package/extensions/ublock/img/flags-of-the-world/vu.png +0 -0
  552. package/extensions/ublock/img/flags-of-the-world/wf.png +0 -0
  553. package/extensions/ublock/img/flags-of-the-world/ws.png +0 -0
  554. package/extensions/ublock/img/flags-of-the-world/xk.png +0 -0
  555. package/extensions/ublock/img/flags-of-the-world/ye.png +0 -0
  556. package/extensions/ublock/img/flags-of-the-world/yt.png +0 -0
  557. package/extensions/ublock/img/flags-of-the-world/za.png +0 -0
  558. package/extensions/ublock/img/flags-of-the-world/zm.png +0 -0
  559. package/extensions/ublock/img/flags-of-the-world/zw.png +0 -0
  560. package/extensions/ublock/img/fontawesome/LICENSE.txt +25 -0
  561. package/extensions/ublock/img/fontawesome/fontawesome-defs.svg +79 -0
  562. package/extensions/ublock/img/help16.png +0 -0
  563. package/extensions/ublock/img/icon_128.png +0 -0
  564. package/extensions/ublock/img/icon_16-loading.png +0 -0
  565. package/extensions/ublock/img/icon_16-off.png +0 -0
  566. package/extensions/ublock/img/icon_16.png +0 -0
  567. package/extensions/ublock/img/icon_32-loading.png +0 -0
  568. package/extensions/ublock/img/icon_32-off.png +0 -0
  569. package/extensions/ublock/img/icon_32.png +0 -0
  570. package/extensions/ublock/img/icon_64-loading.png +0 -0
  571. package/extensions/ublock/img/icon_64-off.png +0 -0
  572. package/extensions/ublock/img/icon_64.png +0 -0
  573. package/extensions/ublock/img/material-design.svg +16 -0
  574. package/extensions/ublock/img/photon.svg +16 -0
  575. package/extensions/ublock/img/ublock-defs.svg +27 -0
  576. package/extensions/ublock/img/ublock.svg +44 -0
  577. package/extensions/ublock/is-webrtc-supported.html +9 -0
  578. package/extensions/ublock/js/1p-filters.js +336 -0
  579. package/extensions/ublock/js/3p-filters.js +867 -0
  580. package/extensions/ublock/js/about.js +34 -0
  581. package/extensions/ublock/js/advanced-settings.js +194 -0
  582. package/extensions/ublock/js/asset-viewer.js +112 -0
  583. package/extensions/ublock/js/assets.js +1448 -0
  584. package/extensions/ublock/js/background.js +404 -0
  585. package/extensions/ublock/js/base64-custom.js +246 -0
  586. package/extensions/ublock/js/benchmarks.js +421 -0
  587. package/extensions/ublock/js/biditrie.js +947 -0
  588. package/extensions/ublock/js/cachestorage.js +510 -0
  589. package/extensions/ublock/js/click2load.js +60 -0
  590. package/extensions/ublock/js/cloud-ui.js +238 -0
  591. package/extensions/ublock/js/code-viewer.js +311 -0
  592. package/extensions/ublock/js/codemirror/search-thread.js +199 -0
  593. package/extensions/ublock/js/codemirror/search.js +504 -0
  594. package/extensions/ublock/js/codemirror/ubo-dynamic-filtering.js +239 -0
  595. package/extensions/ublock/js/codemirror/ubo-static-filtering.js +1126 -0
  596. package/extensions/ublock/js/commands.js +181 -0
  597. package/extensions/ublock/js/console.js +59 -0
  598. package/extensions/ublock/js/contentscript-extra.js +662 -0
  599. package/extensions/ublock/js/contentscript.js +1366 -0
  600. package/extensions/ublock/js/contextmenu.js +270 -0
  601. package/extensions/ublock/js/cosmetic-filtering.js +983 -0
  602. package/extensions/ublock/js/dashboard-common.js +215 -0
  603. package/extensions/ublock/js/dashboard.js +166 -0
  604. package/extensions/ublock/js/devtools.js +184 -0
  605. package/extensions/ublock/js/diff-updater.js +288 -0
  606. package/extensions/ublock/js/document-blocked.js +230 -0
  607. package/extensions/ublock/js/dom.js +213 -0
  608. package/extensions/ublock/js/dyna-rules.js +678 -0
  609. package/extensions/ublock/js/dynamic-net-filtering.js +488 -0
  610. package/extensions/ublock/js/epicker-ui.js +924 -0
  611. package/extensions/ublock/js/fa-icons.js +129 -0
  612. package/extensions/ublock/js/filtering-context.js +461 -0
  613. package/extensions/ublock/js/filtering-engines.js +50 -0
  614. package/extensions/ublock/js/hnswitches.js +289 -0
  615. package/extensions/ublock/js/hntrie.js +780 -0
  616. package/extensions/ublock/js/html-filtering.js +465 -0
  617. package/extensions/ublock/js/httpheader-filtering.js +213 -0
  618. package/extensions/ublock/js/i18n.js +346 -0
  619. package/extensions/ublock/js/is-webrtc-supported.js +52 -0
  620. package/extensions/ublock/js/logger-ui-inspector.js +652 -0
  621. package/extensions/ublock/js/logger-ui.js +3028 -0
  622. package/extensions/ublock/js/logger.js +84 -0
  623. package/extensions/ublock/js/lz4.js +190 -0
  624. package/extensions/ublock/js/messaging.js +2095 -0
  625. package/extensions/ublock/js/pagestore.js +1140 -0
  626. package/extensions/ublock/js/popup-fenix.js +1529 -0
  627. package/extensions/ublock/js/redirect-engine.js +494 -0
  628. package/extensions/ublock/js/redirect-resources.js +193 -0
  629. package/extensions/ublock/js/reverselookup-worker.js +287 -0
  630. package/extensions/ublock/js/reverselookup.js +223 -0
  631. package/extensions/ublock/js/scriptlet-filtering.js +556 -0
  632. package/extensions/ublock/js/scriptlets/cosmetic-logger.js +376 -0
  633. package/extensions/ublock/js/scriptlets/cosmetic-off.js +48 -0
  634. package/extensions/ublock/js/scriptlets/cosmetic-on.js +48 -0
  635. package/extensions/ublock/js/scriptlets/cosmetic-report.js +142 -0
  636. package/extensions/ublock/js/scriptlets/dom-inspector.js +906 -0
  637. package/extensions/ublock/js/scriptlets/dom-survey-elements.js +72 -0
  638. package/extensions/ublock/js/scriptlets/dom-survey-scripts.js +126 -0
  639. package/extensions/ublock/js/scriptlets/epicker.js +1365 -0
  640. package/extensions/ublock/js/scriptlets/load-3p-css.js +67 -0
  641. package/extensions/ublock/js/scriptlets/load-large-media-all.js +62 -0
  642. package/extensions/ublock/js/scriptlets/load-large-media-interactive.js +299 -0
  643. package/extensions/ublock/js/scriptlets/noscript-spoof.js +89 -0
  644. package/extensions/ublock/js/scriptlets/should-inject-contentscript.js +40 -0
  645. package/extensions/ublock/js/scriptlets/subscriber.js +113 -0
  646. package/extensions/ublock/js/scriptlets/updater.js +101 -0
  647. package/extensions/ublock/js/settings.js +317 -0
  648. package/extensions/ublock/js/start.js +509 -0
  649. package/extensions/ublock/js/static-dnr-filtering.js +497 -0
  650. package/extensions/ublock/js/static-ext-filtering-db.js +171 -0
  651. package/extensions/ublock/js/static-ext-filtering.js +184 -0
  652. package/extensions/ublock/js/static-filtering-io.js +144 -0
  653. package/extensions/ublock/js/static-filtering-parser.js +4459 -0
  654. package/extensions/ublock/js/static-net-filtering.js +5631 -0
  655. package/extensions/ublock/js/storage.js +1683 -0
  656. package/extensions/ublock/js/support.js +335 -0
  657. package/extensions/ublock/js/tab.js +1178 -0
  658. package/extensions/ublock/js/tasks.js +42 -0
  659. package/extensions/ublock/js/text-encode.js +275 -0
  660. package/extensions/ublock/js/text-utils.js +107 -0
  661. package/extensions/ublock/js/theme.js +151 -0
  662. package/extensions/ublock/js/traffic.js +1260 -0
  663. package/extensions/ublock/js/ublock.js +696 -0
  664. package/extensions/ublock/js/uri-utils.js +175 -0
  665. package/extensions/ublock/js/url-net-filtering.js +336 -0
  666. package/extensions/ublock/js/utils.js +208 -0
  667. package/extensions/ublock/js/vapi-background-ext.js +254 -0
  668. package/extensions/ublock/js/vapi-background.js +1802 -0
  669. package/extensions/ublock/js/vapi-client-extra.js +312 -0
  670. package/extensions/ublock/js/vapi-client.js +280 -0
  671. package/extensions/ublock/js/vapi-common.js +308 -0
  672. package/extensions/ublock/js/vapi.js +89 -0
  673. package/extensions/ublock/js/wasm/README.md +24 -0
  674. package/extensions/ublock/js/wasm/biditrie.wasm +0 -0
  675. package/extensions/ublock/js/wasm/biditrie.wat +728 -0
  676. package/extensions/ublock/js/wasm/hntrie.wasm +0 -0
  677. package/extensions/ublock/js/wasm/hntrie.wat +724 -0
  678. package/extensions/ublock/js/webext.js +164 -0
  679. package/extensions/ublock/js/whitelist.js +258 -0
  680. package/extensions/ublock/lib/codemirror/LICENSE +21 -0
  681. package/extensions/ublock/lib/codemirror/README.md +47 -0
  682. package/extensions/ublock/lib/codemirror/addon/comment/comment.js +211 -0
  683. package/extensions/ublock/lib/codemirror/addon/display/panel.js +133 -0
  684. package/extensions/ublock/lib/codemirror/addon/edit/closebrackets.js +201 -0
  685. package/extensions/ublock/lib/codemirror/addon/edit/matchbrackets.js +160 -0
  686. package/extensions/ublock/lib/codemirror/addon/fold/foldcode.js +157 -0
  687. package/extensions/ublock/lib/codemirror/addon/fold/foldgutter.css +20 -0
  688. package/extensions/ublock/lib/codemirror/addon/fold/foldgutter.js +163 -0
  689. package/extensions/ublock/lib/codemirror/addon/hint/show-hint.css +36 -0
  690. package/extensions/ublock/lib/codemirror/addon/hint/show-hint.js +509 -0
  691. package/extensions/ublock/lib/codemirror/addon/merge/merge.css +119 -0
  692. package/extensions/ublock/lib/codemirror/addon/merge/merge.js +1006 -0
  693. package/extensions/ublock/lib/codemirror/addon/scroll/annotatescrollbar.js +128 -0
  694. package/extensions/ublock/lib/codemirror/addon/search/matchesonscrollbar.css +8 -0
  695. package/extensions/ublock/lib/codemirror/addon/search/searchcursor.js +296 -0
  696. package/extensions/ublock/lib/codemirror/addon/selection/active-line.js +72 -0
  697. package/extensions/ublock/lib/codemirror/lib/codemirror.css +350 -0
  698. package/extensions/ublock/lib/codemirror/lib/codemirror.js +9800 -0
  699. package/extensions/ublock/lib/codemirror/mode/css/css.js +864 -0
  700. package/extensions/ublock/lib/codemirror/mode/htmlmixed/htmlmixed.js +153 -0
  701. package/extensions/ublock/lib/codemirror/mode/javascript/javascript.js +942 -0
  702. package/extensions/ublock/lib/codemirror/mode/xml/xml.js +413 -0
  703. package/extensions/ublock/lib/codemirror/theme/night.css +27 -0
  704. package/extensions/ublock/lib/csstree/LICENSE +19 -0
  705. package/extensions/ublock/lib/csstree/css-tree.js +17 -0
  706. package/extensions/ublock/lib/diff/README.md +34 -0
  707. package/extensions/ublock/lib/diff/swatinem_diff.js +272 -0
  708. package/extensions/ublock/lib/hsluv/LICENSE +20 -0
  709. package/extensions/ublock/lib/hsluv/README +3 -0
  710. package/extensions/ublock/lib/hsluv/hsluv-0.1.0.min.js +8 -0
  711. package/extensions/ublock/lib/js-beautify/LICENSE +9 -0
  712. package/extensions/ublock/lib/js-beautify/README +5 -0
  713. package/extensions/ublock/lib/js-beautify/beautifier.min.js +2 -0
  714. package/extensions/ublock/lib/lz4/README.md +52 -0
  715. package/extensions/ublock/lib/lz4/lz4-block-codec-any.js +151 -0
  716. package/extensions/ublock/lib/lz4/lz4-block-codec-js.js +297 -0
  717. package/extensions/ublock/lib/lz4/lz4-block-codec-wasm.js +195 -0
  718. package/extensions/ublock/lib/lz4/lz4-block-codec.wasm +0 -0
  719. package/extensions/ublock/lib/lz4/lz4-block-codec.wat +745 -0
  720. package/extensions/ublock/lib/publicsuffixlist/publicsuffixlist.js +641 -0
  721. package/extensions/ublock/lib/publicsuffixlist/wasm/README.md +29 -0
  722. package/extensions/ublock/lib/publicsuffixlist/wasm/publicsuffixlist.wasm +0 -0
  723. package/extensions/ublock/lib/publicsuffixlist/wasm/publicsuffixlist.wat +322 -0
  724. package/extensions/ublock/lib/punycode.js +493 -0
  725. package/extensions/ublock/lib/regexanalyzer/CHANGES.md +15 -0
  726. package/extensions/ublock/lib/regexanalyzer/README.md +14 -0
  727. package/extensions/ublock/lib/regexanalyzer/regex.js +2276 -0
  728. package/extensions/ublock/logger-ui.html +232 -0
  729. package/extensions/ublock/managed_storage.json +73 -0
  730. package/extensions/ublock/manifest.json +115 -0
  731. package/extensions/ublock/no-dashboard.html +27 -0
  732. package/extensions/ublock/popup-fenix.html +114 -0
  733. package/extensions/ublock/settings.html +98 -0
  734. package/extensions/ublock/support.html +131 -0
  735. package/extensions/ublock/web_accessible_resources/1x1.gif +0 -0
  736. package/extensions/ublock/web_accessible_resources/2x2.png +0 -0
  737. package/extensions/ublock/web_accessible_resources/32x32.png +0 -0
  738. package/extensions/ublock/web_accessible_resources/3x2.png +0 -0
  739. package/extensions/ublock/web_accessible_resources/README.txt +11 -0
  740. package/extensions/ublock/web_accessible_resources/addthis_widget.js +39 -0
  741. package/extensions/ublock/web_accessible_resources/amazon_ads.js +70 -0
  742. package/extensions/ublock/web_accessible_resources/amazon_apstag.js +62 -0
  743. package/extensions/ublock/web_accessible_resources/ampproject_v0.js +34 -0
  744. package/extensions/ublock/web_accessible_resources/chartbeat.js +30 -0
  745. package/extensions/ublock/web_accessible_resources/click2load.html +28 -0
  746. package/extensions/ublock/web_accessible_resources/doubleclick_instream_ad_status.js +1 -0
  747. package/extensions/ublock/web_accessible_resources/empty +0 -0
  748. package/extensions/ublock/web_accessible_resources/epicker-ui.html +76 -0
  749. package/extensions/ublock/web_accessible_resources/fingerprint2.js +55 -0
  750. package/extensions/ublock/web_accessible_resources/fingerprint3.js +45 -0
  751. package/extensions/ublock/web_accessible_resources/google-analytics_analytics.js +110 -0
  752. package/extensions/ublock/web_accessible_resources/google-analytics_cx_api.js +36 -0
  753. package/extensions/ublock/web_accessible_resources/google-analytics_ga.js +130 -0
  754. package/extensions/ublock/web_accessible_resources/google-analytics_inpage_linkid.js +28 -0
  755. package/extensions/ublock/web_accessible_resources/google-ima.js +855 -0
  756. package/extensions/ublock/web_accessible_resources/googlesyndication_adsbygoogle.js +56 -0
  757. package/extensions/ublock/web_accessible_resources/googletagmanager_gtm.js +43 -0
  758. package/extensions/ublock/web_accessible_resources/googletagservices_gpt.js +153 -0
  759. package/extensions/ublock/web_accessible_resources/hd-main.js +46 -0
  760. package/extensions/ublock/web_accessible_resources/ligatus_angular-tag.js +29 -0
  761. package/extensions/ublock/web_accessible_resources/monkeybroker.js +43 -0
  762. package/extensions/ublock/web_accessible_resources/mxpnl_mixpanel.js +51 -0
  763. package/extensions/ublock/web_accessible_resources/nobab.js +87 -0
  764. package/extensions/ublock/web_accessible_resources/nobab2.js +42 -0
  765. package/extensions/ublock/web_accessible_resources/noeval-silent.js +28 -0
  766. package/extensions/ublock/web_accessible_resources/noeval.js +30 -0
  767. package/extensions/ublock/web_accessible_resources/nofab.js +67 -0
  768. package/extensions/ublock/web_accessible_resources/noop-0.1s.mp3 +0 -0
  769. package/extensions/ublock/web_accessible_resources/noop-0.5s.mp3 +0 -0
  770. package/extensions/ublock/web_accessible_resources/noop-1s.mp4 +0 -0
  771. package/extensions/ublock/web_accessible_resources/noop-vmap1.0.xml +1 -0
  772. package/extensions/ublock/web_accessible_resources/noop.css +1 -0
  773. package/extensions/ublock/web_accessible_resources/noop.html +5 -0
  774. package/extensions/ublock/web_accessible_resources/noop.js +3 -0
  775. package/extensions/ublock/web_accessible_resources/noop.json +1 -0
  776. package/extensions/ublock/web_accessible_resources/noop.txt +1 -0
  777. package/extensions/ublock/web_accessible_resources/outbrain-widget.js +72 -0
  778. package/extensions/ublock/web_accessible_resources/popads-dummy.js +30 -0
  779. package/extensions/ublock/web_accessible_resources/popads.js +40 -0
  780. package/extensions/ublock/web_accessible_resources/prebid-ads.js +26 -0
  781. package/extensions/ublock/web_accessible_resources/scorecardresearch_beacon.js +31 -0
  782. package/extensions/ublock/whitelist.html +63 -0
  783. package/external/.gitkeep +0 -0
  784. package/fonts/Calibri Bold Italic.ttf +0 -0
  785. package/fonts/Calibri Bold.TTF +0 -0
  786. package/fonts/Calibri Italic.ttf +0 -0
  787. package/fonts/Calibri Light Italic.ttf +0 -0
  788. package/fonts/Calibri Light.ttf +0 -0
  789. package/fonts/Calibri Regular.ttf +0 -0
  790. package/fonts/Emoji.ttf +0 -0
  791. package/fonts/SegoeUI-Bold.ttf +0 -0
  792. package/fonts/SegoeUI-Light.ttf +0 -0
  793. package/fonts/SegoeUI-Regular.ttf +0 -0
  794. package/fonts/SegoeUI-Semibold.ttf +0 -0
  795. package/fonts/SegoeUI-Semilight.ttf +0 -0
  796. package/fonts/Tahoma Bold.ttf +0 -0
  797. package/fonts/Tahoma.ttf +0 -0
  798. package/fonts/fonts.conf +21 -0
  799. package/package.json +177 -0
  800. package/scripts/build-function.js +18 -0
  801. package/scripts/build-open-api.js +274 -0
  802. package/scripts/build-schemas.js +86 -0
  803. package/scripts/build-selectors.js +36 -0
  804. package/scripts/clean.js +7 -0
  805. package/scripts/install-adblock.js +45 -0
  806. package/scripts/install-cdp-json.js +37 -0
  807. package/scripts/start.sh +30 -0
  808. package/scripts/test.sh +17 -0
  809. package/src/browserless.ts +253 -0
  810. package/src/browsers/cdp-chromium.ts +422 -0
  811. package/src/browsers/index.ts +296 -0
  812. package/src/browsers/playwright-chromium.ts +168 -0
  813. package/src/browsers/playwright-firefox.ts +161 -0
  814. package/src/browsers/playwright-webkit.ts +161 -0
  815. package/src/config.ts +426 -0
  816. package/src/constants.ts +4 -0
  817. package/src/exports.ts +23 -0
  818. package/src/file-system.ts +54 -0
  819. package/src/hooks.ts +37 -0
  820. package/src/http.ts +157 -0
  821. package/src/index.ts +41 -0
  822. package/src/limiter.spec.ts +365 -0
  823. package/src/limiter.ts +225 -0
  824. package/src/metrics.spec.ts +49 -0
  825. package/src/metrics.ts +108 -0
  826. package/src/mime-types.ts +332 -0
  827. package/src/monitoring.ts +53 -0
  828. package/src/routes/chromium/http/content-post.ts +238 -0
  829. package/src/routes/chromium/http/download-post.ts +162 -0
  830. package/src/routes/chromium/http/function-post.ts +98 -0
  831. package/src/routes/chromium/http/pdf-post.ts +234 -0
  832. package/src/routes/chromium/http/performance.ts +71 -0
  833. package/src/routes/chromium/http/scrape-post.ts +439 -0
  834. package/src/routes/chromium/http/screenshot-post.ts +262 -0
  835. package/src/routes/chromium/tests/content.spec.ts +340 -0
  836. package/src/routes/chromium/tests/download.spec.ts +77 -0
  837. package/src/routes/chromium/tests/function.spec.ts +279 -0
  838. package/src/routes/chromium/tests/pdf.spec.ts +375 -0
  839. package/src/routes/chromium/tests/performance.spec.ts +155 -0
  840. package/src/routes/chromium/tests/scrape.spec.ts +414 -0
  841. package/src/routes/chromium/tests/screenshot.spec.ts +387 -0
  842. package/src/routes/chromium/tests/websocket.spec.ts +407 -0
  843. package/src/routes/chromium/utils/function/client.ts +99 -0
  844. package/src/routes/chromium/utils/function/handler.ts +172 -0
  845. package/src/routes/chromium/utils/performance/child.ts +38 -0
  846. package/src/routes/chromium/utils/performance/main.ts +90 -0
  847. package/src/routes/chromium/utils/performance/types.ts +24 -0
  848. package/src/routes/chromium/ws/browser.ts +31 -0
  849. package/src/routes/chromium/ws/cdp-chromium.ts +31 -0
  850. package/src/routes/chromium/ws/page.ts +31 -0
  851. package/src/routes/chromium/ws/playwright-chromium.ts +44 -0
  852. package/src/routes/firefox/tests/websocket.spec.ts +146 -0
  853. package/src/routes/firefox/ws/playwright-firefox.ts +44 -0
  854. package/src/routes/management/http/config-get.ts +82 -0
  855. package/src/routes/management/http/metrics-get.ts +43 -0
  856. package/src/routes/management/http/metrics-total-get.ts +89 -0
  857. package/src/routes/management/http/sessions-get.ts +39 -0
  858. package/src/routes/management/http/static-get.ts +109 -0
  859. package/src/routes/management/tests/management.spec.ts +71 -0
  860. package/src/routes/webkit/tests/websocket.spec.ts +146 -0
  861. package/src/routes/webkit/ws/playwright-webkit.ts +44 -0
  862. package/src/server.ts +609 -0
  863. package/src/shim.spec.ts +154 -0
  864. package/src/shim.ts +78 -0
  865. package/src/types.ts +470 -0
  866. package/src/utils.ts +787 -0
  867. package/src/webhooks.ts +50 -0
  868. package/static/docs/browserless-logo.png +0 -0
  869. package/static/docs/docs.js +2 -0
  870. package/static/docs/index.html +71 -0
  871. package/static/docs/swagger.json +4232 -0
  872. package/static/favicon-32x32.png +0 -0
  873. package/static/function/client.js +31623 -0
  874. package/static/function/index.html +12 -0
  875. package/tsconfig.json +31 -0
@@ -0,0 +1,1178 @@
1
+ /*******************************************************************************
2
+
3
+ uBlock Origin - a browser extension to block requests.
4
+ Copyright (C) 2014-present Raymond Hill
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see {http://www.gnu.org/licenses/}.
18
+
19
+ Home: https://github.com/gorhill/uBlock
20
+ */
21
+
22
+ 'use strict';
23
+
24
+ /******************************************************************************/
25
+
26
+ import contextMenu from './contextmenu.js';
27
+ import logger from './logger.js';
28
+ import scriptletFilteringEngine from './scriptlet-filtering.js';
29
+ import staticNetFilteringEngine from './static-net-filtering.js';
30
+ import µb from './background.js';
31
+ import webext from './webext.js';
32
+ import { PageStore } from './pagestore.js';
33
+ import { i18n$ } from './i18n.js';
34
+
35
+ import {
36
+ sessionFirewall,
37
+ sessionSwitches,
38
+ sessionURLFiltering,
39
+ } from './filtering-engines.js';
40
+
41
+ import {
42
+ domainFromHostname,
43
+ hostnameFromURI,
44
+ originFromURI,
45
+ } from './uri-utils.js';
46
+
47
+ /******************************************************************************/
48
+ /******************************************************************************/
49
+
50
+ // https://github.com/gorhill/httpswitchboard/issues/303
51
+ // Any scheme other than 'http' and 'https' is remapped into a fake
52
+ // URL which trick the rest of µBlock into being able to process an
53
+ // otherwise unmanageable scheme. µBlock needs web page to have a proper
54
+ // hostname to work properly, so just like the 'chromium-behind-the-scene'
55
+ // fake domain name, we map unknown schemes into a fake '{scheme}-scheme'
56
+ // hostname. This way, for a specific scheme you can create scope with
57
+ // rules which will apply only to that scheme.
58
+
59
+ µb.normalizeTabURL = (( ) => {
60
+ const tabURLNormalizer = new URL('about:blank');
61
+
62
+ return (tabId, tabURL) => {
63
+ if ( tabId < 0 ) {
64
+ return 'http://behind-the-scene/';
65
+ }
66
+ try {
67
+ tabURLNormalizer.href = tabURL;
68
+ } catch(ex) {
69
+ return tabURL;
70
+ }
71
+ const protocol = tabURLNormalizer.protocol.slice(0, -1);
72
+ if ( protocol === 'https' || protocol === 'http' ) {
73
+ return tabURLNormalizer.href;
74
+ }
75
+
76
+ let fakeHostname = protocol + '-scheme';
77
+
78
+ if ( tabURLNormalizer.hostname !== '' ) {
79
+ fakeHostname = tabURLNormalizer.hostname + '.' + fakeHostname;
80
+ } else if ( protocol === 'about' && protocol.pathname !== '' ) {
81
+ fakeHostname = tabURLNormalizer.pathname + '.' + fakeHostname;
82
+ }
83
+
84
+ return `http://${fakeHostname}/`;
85
+ };
86
+ })();
87
+
88
+ /******************************************************************************/
89
+
90
+ // https://github.com/gorhill/uBlock/issues/99
91
+ // https://github.com/gorhill/uBlock/issues/991
92
+ //
93
+ // popup:
94
+ // Test/close target URL
95
+ // popunder:
96
+ // Test/close opener URL
97
+ //
98
+ // popup filter match:
99
+ // 0 = false
100
+ // 1 = true
101
+ //
102
+ // opener: 0 0 1 1
103
+ // target: 0 1 0 1
104
+ // ---- ---- ---- ----
105
+ // result: a b c d
106
+ //
107
+ // a: do nothing
108
+ // b: close target
109
+ // c: close opener
110
+ // d: close target
111
+
112
+ const onPopupUpdated = (( ) => {
113
+ // https://github.com/gorhill/uBlock/commit/1d448b85b2931412508aa01bf899e0b6f0033626#commitcomment-14944764
114
+ // See if two URLs are different, disregarding scheme -- because the
115
+ // scheme can be unilaterally changed by the browser.
116
+ // https://github.com/gorhill/uBlock/issues/1378
117
+ // Maybe no link element was clicked.
118
+ // https://github.com/gorhill/uBlock/issues/3287
119
+ // Do not bail out if the target URL has no hostname.
120
+ const areDifferentURLs = function(a, b) {
121
+ if ( b === '' ) { return true; }
122
+ if ( b.startsWith('about:') ) { return false; }
123
+ let pos = a.indexOf('://');
124
+ if ( pos === -1 ) { return false; }
125
+ a = a.slice(pos);
126
+ pos = b.indexOf('://');
127
+ if ( pos !== -1 ) {
128
+ b = b.slice(pos);
129
+ }
130
+ return b !== a;
131
+ };
132
+
133
+ const popupMatch = function(
134
+ fctxt,
135
+ rootOpenerURL,
136
+ localOpenerURL,
137
+ targetURL,
138
+ popupType = 'popup'
139
+ ) {
140
+ // https://github.com/chrisaljoudi/uBlock/issues/323
141
+ // https://github.com/chrisaljoudi/uBlock/issues/1142
142
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/1616
143
+ // Don't block if uBO is turned off in popup's context
144
+ if (
145
+ µb.getNetFilteringSwitch(targetURL) === false ||
146
+ µb.getNetFilteringSwitch(µb.normalizeTabURL(0, targetURL)) === false
147
+ ) {
148
+ return 0;
149
+ }
150
+
151
+ fctxt.setTabOriginFromURL(rootOpenerURL)
152
+ .setDocOriginFromURL(localOpenerURL || rootOpenerURL)
153
+ .setURL(targetURL)
154
+ .setType('popup');
155
+
156
+ // https://github.com/gorhill/uBlock/issues/1735
157
+ // Do not bail out on `data:` URI, they are commonly used for popups.
158
+ // https://github.com/uBlockOrigin/uAssets/issues/255
159
+ // Do not bail out on `about:blank`: an `about:blank` popup can be
160
+ // opened, with the sole purpose to serve as an intermediary in
161
+ // a sequence of chained popups.
162
+ // https://github.com/uBlockOrigin/uAssets/issues/263#issuecomment-272615772
163
+ // Do not bail out, period: the static filtering engine must be
164
+ // able to examine all sorts of URLs for popup filtering purpose.
165
+
166
+ // Dynamic filtering makes sense only when we have a valid opener
167
+ // hostname.
168
+ // https://github.com/gorhill/uBlock/commit/1d448b85b2931412508aa01bf899e0b6f0033626#commitcomment-14944764
169
+ // Ignore bad target URL. On Firefox, an `about:blank` tab may be
170
+ // opened for a new tab before it is filled in with the real target
171
+ // URL.
172
+ if ( fctxt.getTabHostname() !== '' && targetURL !== 'about:blank' ) {
173
+ // Check per-site switch first
174
+ // https://github.com/gorhill/uBlock/issues/3060
175
+ // - The no-popups switch must apply only to popups, not to
176
+ // popunders.
177
+ if (
178
+ popupType === 'popup' &&
179
+ sessionSwitches.evaluateZ(
180
+ 'no-popups',
181
+ fctxt.getTabHostname()
182
+ )
183
+ ) {
184
+ fctxt.filter = {
185
+ raw: 'no-popups: ' + sessionSwitches.z + ' true',
186
+ result: 1,
187
+ source: 'switch'
188
+ };
189
+ return 1;
190
+ }
191
+
192
+ // https://github.com/gorhill/uBlock/issues/581
193
+ // Take into account popup-specific rules in dynamic URL
194
+ // filtering, OR generic allow rules.
195
+ let result = sessionURLFiltering.evaluateZ(
196
+ fctxt.getTabHostname(),
197
+ targetURL,
198
+ popupType
199
+ );
200
+ if (
201
+ result === 1 && sessionURLFiltering.type === popupType ||
202
+ result === 2
203
+ ) {
204
+ fctxt.filter = sessionURLFiltering.toLogData();
205
+ return result;
206
+ }
207
+
208
+ // https://github.com/gorhill/uBlock/issues/581
209
+ // Take into account `allow` rules in dynamic filtering: `block`
210
+ // rules are ignored, as block rules are not meant to block
211
+ // specific types like `popup` (just like with static filters).
212
+ result = sessionFirewall.evaluateCellZY(
213
+ fctxt.getTabHostname(),
214
+ fctxt.getHostname(),
215
+ popupType
216
+ );
217
+ if ( result === 2 ) {
218
+ fctxt.filter = sessionFirewall.toLogData();
219
+ return 2;
220
+ }
221
+ }
222
+
223
+ fctxt.type = popupType;
224
+ const result = staticNetFilteringEngine.matchRequest(fctxt, 0b0001);
225
+ if ( result !== 0 ) {
226
+ fctxt.filter = staticNetFilteringEngine.toLogData();
227
+ return result;
228
+ }
229
+
230
+ return 0;
231
+ };
232
+
233
+ const mapPopunderResult = function(
234
+ fctxt,
235
+ popunderURL,
236
+ popunderHostname,
237
+ result
238
+ ) {
239
+ if ( fctxt.filter === undefined || fctxt.filter !== 'static' ) {
240
+ return 0;
241
+ }
242
+ if ( fctxt.filter.isUntokenized() ) {
243
+ return 0;
244
+ }
245
+ if ( fctxt.filter.isPureHostname() ) {
246
+ return result;
247
+ }
248
+ const re = new RegExp(fctxt.filter.regex, 'i');
249
+ const matches = re.exec(popunderURL);
250
+ if ( matches === null ) { return 0; }
251
+ const beg = matches.index;
252
+ const end = beg + matches[0].length;
253
+ const pos = popunderURL.indexOf(popunderHostname);
254
+ if ( pos === -1 ) { return 0; }
255
+ // https://github.com/gorhill/uBlock/issues/1471
256
+ // We test whether the opener hostname as at least one character
257
+ // within matched portion of URL.
258
+ // https://github.com/gorhill/uBlock/issues/1903
259
+ // Ignore filters which cause a match before the start of the
260
+ // hostname in the URL.
261
+ return beg >= pos && beg < pos + popunderHostname.length && end > pos
262
+ ? result
263
+ : 0;
264
+ };
265
+
266
+ const popunderMatch = function(
267
+ fctxt,
268
+ rootOpenerURL,
269
+ localOpenerURL,
270
+ targetURL
271
+ ) {
272
+ let result = popupMatch(
273
+ fctxt,
274
+ targetURL,
275
+ undefined,
276
+ rootOpenerURL,
277
+ 'popunder'
278
+ );
279
+ if ( result === 1 ) { return result; }
280
+
281
+ // https://github.com/gorhill/uBlock/issues/1010#issuecomment-186824878
282
+ // Check the opener tab as if it were the newly opened tab: if there
283
+ // is a hit against a popup filter, and if the matching filter is not
284
+ // a broad one, we will consider the opener tab to be a popunder tab.
285
+ // For now, a "broad" filter is one which does not touch any part of
286
+ // the hostname part of the opener URL.
287
+ let popunderURL = rootOpenerURL,
288
+ popunderHostname = hostnameFromURI(popunderURL);
289
+ if ( popunderHostname === '' ) { return 0; }
290
+
291
+ result = mapPopunderResult(
292
+ fctxt,
293
+ popunderURL,
294
+ popunderHostname,
295
+ popupMatch(fctxt, targetURL, undefined, popunderURL)
296
+ );
297
+ if ( result !== 0 ) { return result; }
298
+
299
+ // https://github.com/gorhill/uBlock/issues/1598
300
+ // Try to find a match against origin part of the opener URL.
301
+ popunderURL = originFromURI(popunderURL);
302
+ if ( popunderURL === '' ) { return 0; }
303
+
304
+ return mapPopunderResult(
305
+ fctxt,
306
+ popunderURL,
307
+ popunderHostname,
308
+ popupMatch(fctxt, targetURL, undefined, popunderURL)
309
+ );
310
+ };
311
+
312
+ return function(targetTabId, openerDetails) {
313
+ // Opener details.
314
+ const openerTabId = openerDetails.tabId;
315
+ let tabContext = µb.tabContextManager.lookup(openerTabId);
316
+ if ( tabContext === null ) { return; }
317
+ const rootOpenerURL = tabContext.rawURL;
318
+ if ( rootOpenerURL === '' ) { return; }
319
+ const pageStore = µb.pageStoreFromTabId(openerTabId);
320
+
321
+ // https://github.com/uBlockOrigin/uBlock-issues/discussions/2534#discussioncomment-5264792
322
+ // An `about:blank` frame's context is that of the parent context
323
+ let localOpenerURL = openerDetails.frameId !== 0
324
+ ? openerDetails.frameURL
325
+ : undefined;
326
+ if ( localOpenerURL === 'about:blank' && pageStore !== null ) {
327
+ let openerFrameId = openerDetails.frameId;
328
+ do {
329
+ const frame = pageStore.getFrameStore(openerFrameId);
330
+ if ( frame === null ) { break; }
331
+ openerFrameId = frame.parentId;
332
+ const parentFrame = pageStore.getFrameStore(openerFrameId);
333
+ if ( parentFrame === null ) { break; }
334
+ localOpenerURL = parentFrame.frameURL;
335
+ } while ( localOpenerURL === 'about:blank' && openerFrameId !== 0 );
336
+ }
337
+
338
+ // Popup details.
339
+ tabContext = µb.tabContextManager.lookup(targetTabId);
340
+ if ( tabContext === null ) { return; }
341
+ let targetURL = tabContext.rawURL;
342
+ if ( targetURL === '' ) { return; }
343
+
344
+ // https://github.com/gorhill/uBlock/issues/341
345
+ // Allow popups if uBlock is turned off in opener's context.
346
+ if ( µb.getNetFilteringSwitch(rootOpenerURL) === false ) { return; }
347
+
348
+ // https://github.com/gorhill/uBlock/issues/1538
349
+ if (
350
+ µb.getNetFilteringSwitch(
351
+ µb.normalizeTabURL(openerTabId, rootOpenerURL)
352
+ ) === false
353
+ ) {
354
+ return;
355
+ }
356
+
357
+ // If the page URL is that of our document-blocked URL, extract the URL
358
+ // of the page which was blocked.
359
+ targetURL = µb.pageURLFromMaybeDocumentBlockedURL(targetURL);
360
+
361
+ // MUST be reset before code below is called.
362
+ const fctxt = µb.filteringContext.duplicate();
363
+
364
+ // Popup test.
365
+ let popupType = 'popup',
366
+ result = 0;
367
+ // https://github.com/gorhill/uBlock/issues/2919
368
+ // If the target tab matches a clicked link, assume it's legit.
369
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/1912
370
+ // If the target also matches the last clicked link, assume it's
371
+ // legit.
372
+ if (
373
+ areDifferentURLs(targetURL, openerDetails.trustedURL) &&
374
+ areDifferentURLs(targetURL, µb.maybeGoodPopup.url)
375
+ ) {
376
+ result = popupMatch(fctxt, rootOpenerURL, localOpenerURL, targetURL);
377
+ }
378
+
379
+ // Popunder test.
380
+ if ( result === 0 && openerDetails.popunder ) {
381
+ result = popunderMatch(fctxt, rootOpenerURL, localOpenerURL, targetURL);
382
+ if ( result === 1 ) {
383
+ popupType = 'popunder';
384
+ }
385
+ }
386
+
387
+ // Log only for when there was a hit against an actual filter (allow or block).
388
+ // https://github.com/gorhill/uBlock/issues/2776
389
+ if ( logger.enabled ) {
390
+ fctxt.setRealm('network').setType(popupType);
391
+ if ( popupType === 'popup' ) {
392
+ fctxt.setURL(targetURL)
393
+ .setTabId(openerTabId)
394
+ .setTabOriginFromURL(rootOpenerURL)
395
+ .setDocOriginFromURL(localOpenerURL || rootOpenerURL);
396
+ } else {
397
+ fctxt.setURL(rootOpenerURL)
398
+ .setTabId(targetTabId)
399
+ .setTabOriginFromURL(targetURL)
400
+ .setDocOriginFromURL(targetURL);
401
+ }
402
+ fctxt.toLogger();
403
+ }
404
+
405
+ // Not blocked
406
+ if ( result !== 1 ) { return; }
407
+
408
+ // Only if a popup was blocked do we report it in the dynamic
409
+ // filtering pane.
410
+ if ( pageStore ) {
411
+ pageStore.journalAddRequest(fctxt, result);
412
+ pageStore.popupBlockedCount += 1;
413
+ }
414
+
415
+ // Blocked
416
+ if ( µb.userSettings.showIconBadge ) {
417
+ µb.updateToolbarIcon(openerTabId, 0b010);
418
+ }
419
+
420
+ // It is a popup, block and remove the tab.
421
+ if ( popupType === 'popup' ) {
422
+ µb.unbindTabFromPageStore(targetTabId);
423
+ vAPI.tabs.remove(targetTabId, false);
424
+ } else {
425
+ µb.unbindTabFromPageStore(openerTabId);
426
+ vAPI.tabs.remove(openerTabId, true);
427
+ }
428
+
429
+ return true;
430
+ };
431
+ })();
432
+
433
+ /******************************************************************************/
434
+ /******************************************************************************
435
+
436
+ To keep track from which context *exactly* network requests are made. This is
437
+ often tricky for various reasons, and the challenge is not specific to one
438
+ browser.
439
+
440
+ The time at which a URL is assigned to a tab and the time when a network
441
+ request for a root document is made must be assumed to be unrelated: it's all
442
+ asynchronous. There is no guaranteed order in which the two events are fired.
443
+
444
+ Also, other "anomalies" can occur:
445
+
446
+ - a network request for a root document is fired without the corresponding
447
+ tab being really assigned a new URL
448
+ <https://github.com/chrisaljoudi/uBlock/issues/516>
449
+
450
+ - a network request for a secondary resource is labeled with a tab id for
451
+ which no root document was pulled for that tab.
452
+ <https://github.com/chrisaljoudi/uBlock/issues/1001>
453
+
454
+ - a network request for a secondary resource is made without the root
455
+ document to which it belongs being formally bound yet to the proper tab id,
456
+ causing a bad scope to be used for filtering purpose.
457
+ <https://github.com/chrisaljoudi/uBlock/issues/1205>
458
+ <https://github.com/chrisaljoudi/uBlock/issues/1140>
459
+
460
+ So the solution here is to keep a lightweight data structure which only
461
+ purpose is to keep track as accurately as possible of which root document
462
+ belongs to which tab. That's the only purpose, and because of this, there are
463
+ no restrictions for when the URL of a root document can be associated to a tab.
464
+
465
+ Before, the PageStore object was trying to deal with this, but it had to
466
+ enforce some restrictions so as to not descend into one of the above issues, or
467
+ other issues. The PageStore object can only be associated with a tab for which
468
+ a definitive navigation event occurred, because it collects information about
469
+ what occurred in the tab (for example, the number of requests blocked for a
470
+ page).
471
+
472
+ The TabContext objects do not suffer this restriction, and as a result they
473
+ offer the most reliable picture of which root document URL is really associated
474
+ to which tab. Moreover, the TabObject can undo an association from a root
475
+ document, and automatically re-associate with the next most recent. This takes
476
+ care of <https://github.com/chrisaljoudi/uBlock/issues/516>.
477
+
478
+ The PageStore object no longer cache the various information about which
479
+ root document it is currently bound. When it needs to find out, it will always
480
+ defer to the TabContext object, which will provide the real answer. This takes
481
+ case of <https://github.com/chrisaljoudi/uBlock/issues/1205>. In effect, the
482
+ master switch and dynamic filtering rules can be evaluated now properly even
483
+ in the absence of a PageStore object, this was not the case before.
484
+
485
+ Also, the TabContext object will try its best to find a good candidate root
486
+ document URL for when none exists. This takes care of
487
+ <https://github.com/chrisaljoudi/uBlock/issues/1001>.
488
+
489
+ The TabContext manager is self-contained, and it takes care to properly
490
+ housekeep itself.
491
+
492
+ */
493
+
494
+ µb.tabContextManager = (( ) => {
495
+ const tabContexts = new Map();
496
+
497
+ // https://github.com/chrisaljoudi/uBlock/issues/1001
498
+ // This is to be used as last-resort fallback in case a tab is found to not
499
+ // be bound while network requests are fired for the tab.
500
+ let mostRecentRootDocURL = '';
501
+ let mostRecentRootDocURLTimestamp = 0;
502
+
503
+ const popupCandidates = new Map();
504
+
505
+ const PopupCandidate = class {
506
+ constructor(createDetails, openerDetails) {
507
+ this.targetTabId = createDetails.tabId;
508
+ this.opener = {
509
+ tabId: createDetails.sourceTabId,
510
+ tabURL: openerDetails[0].url,
511
+ frameId: createDetails.sourceFrameId,
512
+ frameURL: openerDetails[1].url,
513
+ popunder: false,
514
+ trustedURL: createDetails.sourceTabId === µb.maybeGoodPopup.tabId
515
+ ? µb.maybeGoodPopup.url
516
+ : ''
517
+ };
518
+ this.selfDestructionTimer = vAPI.defer.create(( ) => {
519
+ this.destroy();
520
+ });
521
+ this.launchSelfDestruction();
522
+ }
523
+
524
+ destroy() {
525
+ this.selfDestructionTimer.off();
526
+ popupCandidates.delete(this.targetTabId);
527
+ }
528
+
529
+ launchSelfDestruction() {
530
+ this.selfDestructionTimer.offon(10000);
531
+ }
532
+ };
533
+
534
+ const popupCandidateTest = async function(targetTabId) {
535
+ for ( const [ tabId, candidate ] of popupCandidates ) {
536
+ if (
537
+ targetTabId !== tabId &&
538
+ targetTabId !== candidate.opener.tabId
539
+ ) {
540
+ continue;
541
+ }
542
+ // https://github.com/gorhill/uBlock/issues/3129
543
+ // If the trigger is a change in the opener's URL, mark the entry
544
+ // as candidate for popunder filtering.
545
+ if ( targetTabId === candidate.opener.tabId ) {
546
+ candidate.opener.popunder = true;
547
+ }
548
+ const result = onPopupUpdated(tabId, candidate.opener);
549
+ if ( result === true ) {
550
+ candidate.destroy();
551
+ } else {
552
+ candidate.launchSelfDestruction();
553
+ }
554
+ }
555
+ };
556
+
557
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/1184
558
+ // Do not consider a tab opened from `about:newtab` to be a popup
559
+ // candidate.
560
+
561
+ const onTabCreated = async function(createDetails) {
562
+ const { sourceTabId, sourceFrameId, tabId } = createDetails;
563
+ const popup = popupCandidates.get(tabId);
564
+ if ( popup === undefined ) {
565
+ let openerDetails;
566
+ try {
567
+ openerDetails = await Promise.all([
568
+ webext.webNavigation.getFrame({
569
+ tabId: createDetails.sourceTabId,
570
+ frameId: 0,
571
+ }),
572
+ webext.webNavigation.getFrame({
573
+ tabId: sourceTabId,
574
+ frameId: sourceFrameId,
575
+ }),
576
+ ]);
577
+ }
578
+ catch (reason) {
579
+ return;
580
+ }
581
+ if (
582
+ Array.isArray(openerDetails) === false ||
583
+ openerDetails.length !== 2 ||
584
+ openerDetails[1] === null ||
585
+ openerDetails[1].url === 'about:newtab'
586
+ ) {
587
+ return;
588
+ }
589
+ popupCandidates.set(
590
+ tabId,
591
+ new PopupCandidate(createDetails, openerDetails)
592
+ );
593
+ }
594
+ popupCandidateTest(tabId);
595
+ };
596
+
597
+ const gcPeriod = 10 * 60 * 1000;
598
+
599
+ // A pushed entry is removed from the stack unless it is committed with
600
+ // a set time.
601
+ const StackEntry = function(url, commit) {
602
+ this.url = url;
603
+ this.committed = commit;
604
+ this.tstamp = Date.now();
605
+ };
606
+
607
+ const TabContext = function(tabId) {
608
+ this.tabId = tabId;
609
+ this.stack = [];
610
+ this.rawURL =
611
+ this.normalURL =
612
+ this.origin =
613
+ this.rootHostname =
614
+ this.rootDomain = '';
615
+ this.commitTimer = vAPI.defer.create(( ) => {
616
+ this.onCommit();
617
+ });
618
+ this.gcTimer = vAPI.defer.create(( ) => {
619
+ this.onGC();
620
+ });
621
+ this.onGCBarrier = false;
622
+ this.netFiltering = true;
623
+ this.netFilteringReadTime = 0;
624
+
625
+ tabContexts.set(tabId, this);
626
+ };
627
+
628
+ TabContext.prototype.destroy = function() {
629
+ if ( vAPI.isBehindTheSceneTabId(this.tabId) ) { return; }
630
+ this.gcTimer.off();
631
+ tabContexts.delete(this.tabId);
632
+ };
633
+
634
+ TabContext.prototype.onGC = async function() {
635
+ if ( vAPI.isBehindTheSceneTabId(this.tabId) ) { return; }
636
+ if ( this.onGCBarrier ) { return; }
637
+ this.onGCBarrier = true;
638
+ this.gcTimer.off();
639
+ const tab = await vAPI.tabs.get(this.tabId);
640
+ if ( tab instanceof Object === false || tab.discarded === true ) {
641
+ this.destroy();
642
+ } else {
643
+ this.gcTimer.on(gcPeriod);
644
+ }
645
+ this.onGCBarrier = false;
646
+ };
647
+
648
+ // https://github.com/gorhill/uBlock/issues/248
649
+ // Stack entries have to be committed to stick. Non-committed stack
650
+ // entries are removed after a set delay.
651
+ TabContext.prototype.onCommit = function() {
652
+ if ( vAPI.isBehindTheSceneTabId(this.tabId) ) { return; }
653
+ this.commitTimer.off();
654
+ // Remove uncommitted entries at the top of the stack.
655
+ let i = this.stack.length;
656
+ while ( i-- ) {
657
+ if ( this.stack[i].committed ) { break; }
658
+ }
659
+ // https://github.com/gorhill/uBlock/issues/300
660
+ // If no committed entry was found, fall back on the bottom-most one
661
+ // as being the committed one by default.
662
+ if ( i === -1 && this.stack.length !== 0 ) {
663
+ this.stack[0].committed = true;
664
+ i = 0;
665
+ }
666
+ i += 1;
667
+ if ( i < this.stack.length ) {
668
+ this.stack.length = i;
669
+ this.update();
670
+ }
671
+ };
672
+
673
+ // This takes care of orphanized tab contexts. Can't be started for all
674
+ // contexts, as the behind-the-scene context is permanent -- so we do not
675
+ // want to flush it.
676
+ TabContext.prototype.autodestroy = function() {
677
+ if ( vAPI.isBehindTheSceneTabId(this.tabId) ) { return; }
678
+ this.gcTimer.on(gcPeriod);
679
+ };
680
+
681
+ // Update just force all properties to be updated to match the most recent
682
+ // root URL.
683
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/1954
684
+ // In case of document-blocked page, use the blocked page URL as the
685
+ // context.
686
+ TabContext.prototype.update = function() {
687
+ this.netFilteringReadTime = 0;
688
+ if ( this.stack.length === 0 ) {
689
+ this.rawURL =
690
+ this.normalURL =
691
+ this.origin =
692
+ this.rootHostname =
693
+ this.rootDomain = '';
694
+ return;
695
+ }
696
+ const stackEntry = this.stack[this.stack.length - 1];
697
+ this.rawURL = µb.pageURLFromMaybeDocumentBlockedURL(stackEntry.url);
698
+ this.normalURL = µb.normalizeTabURL(this.tabId, this.rawURL);
699
+ this.origin = originFromURI(this.normalURL);
700
+ this.rootHostname = hostnameFromURI(this.origin);
701
+ this.rootDomain =
702
+ domainFromHostname(this.rootHostname) ||
703
+ this.rootHostname;
704
+ };
705
+
706
+ // Called whenever a candidate root URL is spotted for the tab.
707
+ TabContext.prototype.push = function(url) {
708
+ if ( vAPI.isBehindTheSceneTabId(this.tabId) ) {
709
+ return;
710
+ }
711
+ const count = this.stack.length;
712
+ if ( count !== 0 && this.stack[count - 1].url === url ) {
713
+ return;
714
+ }
715
+ this.stack.push(new StackEntry(url));
716
+ this.update();
717
+ popupCandidateTest(this.tabId);
718
+ this.commitTimer.offon(500);
719
+ };
720
+
721
+ // This tells that the url is definitely the one to be associated with the
722
+ // tab, there is no longer any ambiguity about which root URL is really
723
+ // sitting in which tab.
724
+ TabContext.prototype.commit = function(url) {
725
+ if ( vAPI.isBehindTheSceneTabId(this.tabId) ) { return; }
726
+ if ( this.stack.length !== 0 ) {
727
+ const top = this.stack[this.stack.length - 1];
728
+ if ( top.url === url && top.committed ) { return false; }
729
+ }
730
+ this.stack = [new StackEntry(url, true)];
731
+ this.update();
732
+ return true;
733
+ };
734
+
735
+ TabContext.prototype.getNetFilteringSwitch = function() {
736
+ if ( this.netFilteringReadTime > µb.netWhitelistModifyTime ) {
737
+ return this.netFiltering;
738
+ }
739
+ // https://github.com/chrisaljoudi/uBlock/issues/1078
740
+ // Use both the raw and normalized URLs.
741
+ this.netFiltering = µb.getNetFilteringSwitch(this.normalURL);
742
+ if (
743
+ this.netFiltering &&
744
+ this.rawURL !== this.normalURL &&
745
+ this.rawURL !== ''
746
+ ) {
747
+ this.netFiltering = µb.getNetFilteringSwitch(this.rawURL);
748
+ }
749
+ this.netFilteringReadTime = Date.now();
750
+ return this.netFiltering;
751
+ };
752
+
753
+ // These are to be used for the API of the tab context manager.
754
+
755
+ const push = function(tabId, url) {
756
+ let entry = tabContexts.get(tabId);
757
+ if ( entry === undefined ) {
758
+ entry = new TabContext(tabId);
759
+ entry.autodestroy();
760
+ }
761
+ entry.push(url);
762
+ mostRecentRootDocURL = url;
763
+ mostRecentRootDocURLTimestamp = Date.now();
764
+ return entry;
765
+ };
766
+
767
+ // Find a tab context for a specific tab.
768
+ const lookup = function(tabId) {
769
+ return tabContexts.get(tabId) || null;
770
+ };
771
+
772
+ // Find a tab context for a specific tab. If none is found, attempt to
773
+ // fix this. When all fail, the behind-the-scene context is returned.
774
+ const mustLookup = function(tabId) {
775
+ const entry = tabContexts.get(tabId);
776
+ if ( entry !== undefined ) {
777
+ return entry;
778
+ }
779
+ // https://github.com/chrisaljoudi/uBlock/issues/1025
780
+ // Google Hangout popup opens without a root frame. So for now we will
781
+ // just discard that best-guess root frame if it is too far in the
782
+ // future, at which point it ceases to be a "best guess".
783
+ if (
784
+ mostRecentRootDocURL !== '' &&
785
+ mostRecentRootDocURLTimestamp + 500 < Date.now()
786
+ ) {
787
+ mostRecentRootDocURL = '';
788
+ }
789
+ // https://github.com/chrisaljoudi/uBlock/issues/1001
790
+ // Not a behind-the-scene request, yet no page store found for the
791
+ // tab id: we will thus bind the last-seen root document to the
792
+ // unbound tab. It's a guess, but better than ending up filtering
793
+ // nothing at all.
794
+ if ( mostRecentRootDocURL !== '' ) {
795
+ return push(tabId, mostRecentRootDocURL);
796
+ }
797
+ // If all else fail at finding a page store, re-categorize the
798
+ // request as behind-the-scene. At least this ensures that ultimately
799
+ // the user can still inspect/filter those net requests which were
800
+ // about to fall through the cracks.
801
+ // Example: Chromium + case #12 at
802
+ // http://raymondhill.net/ublock/popup.html
803
+ return tabContexts.get(vAPI.noTabId);
804
+ };
805
+
806
+ // https://github.com/gorhill/uBlock/issues/1735
807
+ // Filter for popups if actually committing.
808
+ const commit = function(tabId, url) {
809
+ let entry = tabContexts.get(tabId);
810
+ if ( entry === undefined ) {
811
+ entry = push(tabId, url);
812
+ } else if ( entry.commit(url) ) {
813
+ popupCandidateTest(tabId);
814
+ }
815
+ return entry;
816
+ };
817
+
818
+ const exists = function(tabId) {
819
+ return tabContexts.get(tabId) !== undefined;
820
+ };
821
+
822
+ // Behind-the-scene tab context
823
+ {
824
+ const entry = new TabContext(vAPI.noTabId);
825
+ entry.stack.push(new StackEntry('', true));
826
+ entry.rawURL = '';
827
+ entry.normalURL = µb.normalizeTabURL(entry.tabId);
828
+ entry.origin = originFromURI(entry.normalURL);
829
+ entry.rootHostname = hostnameFromURI(entry.origin);
830
+ entry.rootDomain = domainFromHostname(entry.rootHostname);
831
+ }
832
+
833
+ // Context object, typically to be used to feed filtering engines.
834
+ const contextJunkyard = [];
835
+ const Context = class {
836
+ constructor(tabId) {
837
+ this.init(tabId);
838
+ }
839
+ init(tabId) {
840
+ const tabContext = lookup(tabId);
841
+ this.rootHostname = tabContext.rootHostname;
842
+ this.rootDomain = tabContext.rootDomain;
843
+ this.pageHostname =
844
+ this.pageDomain =
845
+ this.requestURL =
846
+ this.origin =
847
+ this.requestHostname =
848
+ this.requestDomain = '';
849
+ return this;
850
+ }
851
+ dispose() {
852
+ contextJunkyard.push(this);
853
+ }
854
+ };
855
+
856
+ const createContext = function(tabId) {
857
+ if ( contextJunkyard.length ) {
858
+ return contextJunkyard.pop().init(tabId);
859
+ }
860
+ return new Context(tabId);
861
+ };
862
+
863
+ return {
864
+ push,
865
+ commit,
866
+ lookup,
867
+ mustLookup,
868
+ exists,
869
+ createContext,
870
+ onTabCreated,
871
+ };
872
+ })();
873
+
874
+ /******************************************************************************/
875
+ /******************************************************************************/
876
+
877
+ vAPI.Tabs = class extends vAPI.Tabs {
878
+ onActivated(details) {
879
+ const { tabId } = details;
880
+ if ( vAPI.isBehindTheSceneTabId(tabId) ) { return; }
881
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/757
882
+ const pageStore = µb.pageStoreFromTabId(tabId);
883
+ if ( pageStore === null ) {
884
+ this.onNewTab(tabId);
885
+ return;
886
+ }
887
+ super.onActivated(details);
888
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/680
889
+ µb.updateToolbarIcon(tabId);
890
+ contextMenu.update(tabId);
891
+ }
892
+
893
+ onClosed(tabId) {
894
+ super.onClosed(tabId);
895
+ if ( vAPI.isBehindTheSceneTabId(tabId) ) { return; }
896
+ µb.unbindTabFromPageStore(tabId);
897
+ contextMenu.update();
898
+ }
899
+
900
+ onCreated(details) {
901
+ super.onCreated(details);
902
+ µb.tabContextManager.onTabCreated(details);
903
+ }
904
+
905
+ // When the DOM content of root frame is loaded, this means the tab
906
+ // content has changed.
907
+ //
908
+ // The webRequest.onBeforeRequest() won't be called for everything
909
+ // else than http/https. Thus, in such case, we will bind the tab as
910
+ // early as possible in order to increase the likelihood of a context
911
+ // properly setup if network requests are fired from within the tab.
912
+ // Example: Chromium + case #6 at
913
+ // http://raymondhill.net/ublock/popup.html
914
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-748179731
915
+ // For non-network URIs, defer scriptlet injection to content script. The
916
+ // reason for this is that we need the effective URL and this information
917
+ // is not available at this point.
918
+ //
919
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/2343
920
+ // uBO's isolated world in Firefox just does not work as expected at
921
+ // point, so we have to wait before injecting scriptlets.
922
+ onNavigation(details) {
923
+ super.onNavigation(details);
924
+ const { frameId, tabId, url } = details;
925
+ if ( frameId === 0 ) {
926
+ µb.tabContextManager.commit(tabId, url);
927
+ const pageStore = µb.bindTabToPageStore(tabId, 'tabCommitted', details);
928
+ if ( pageStore !== null ) {
929
+ pageStore.journalAddRootFrame('committed', url);
930
+ }
931
+ }
932
+ const pageStore = µb.pageStoreFromTabId(tabId);
933
+ if ( pageStore === null ) { return; }
934
+ pageStore.setFrameURL(details);
935
+ if ( pageStore.getNetFilteringSwitch() ) {
936
+ scriptletFilteringEngine.injectNow(details);
937
+ }
938
+ }
939
+
940
+ async onNewTab(tabId) {
941
+ const tab = await vAPI.tabs.get(tabId);
942
+ if ( tab === null ) { return; }
943
+ const { id, url = '' } = tab;
944
+ if ( url === '' ) { return; }
945
+ µb.tabContextManager.commit(id, url);
946
+ µb.bindTabToPageStore(id, 'tabUpdated', tab);
947
+ contextMenu.update(id);
948
+ }
949
+
950
+ // It may happen the URL in the tab changes, while the page's document
951
+ // stays the same (for instance, Google Maps). Without this listener,
952
+ // the extension icon won't be properly refreshed.
953
+ onUpdated(tabId, changeInfo, tab) {
954
+ super.onUpdated(tabId, changeInfo, tab);
955
+ if ( !tab.url || tab.url === '' ) { return; }
956
+ if ( !changeInfo.url ) { return; }
957
+ µb.tabContextManager.commit(tabId, changeInfo.url);
958
+ µb.bindTabToPageStore(tabId, 'tabUpdated', tab);
959
+ }
960
+ };
961
+
962
+ vAPI.tabs = new vAPI.Tabs();
963
+
964
+ /******************************************************************************/
965
+ /******************************************************************************/
966
+
967
+ // Create an entry for the tab if it doesn't exist.
968
+
969
+ µb.bindTabToPageStore = function(tabId, context, details = undefined) {
970
+ this.updateToolbarIcon(tabId, 0b111);
971
+
972
+ // Do not create a page store for URLs which are of no interests
973
+ if ( this.tabContextManager.exists(tabId) === false ) {
974
+ this.unbindTabFromPageStore(tabId);
975
+ return null;
976
+ }
977
+
978
+ // Reuse page store if one exists: this allows to guess if a tab is a popup
979
+ let pageStore = this.pageStores.get(tabId);
980
+
981
+ // Tab is not bound
982
+ if ( pageStore === undefined ) {
983
+ pageStore = PageStore.factory(tabId, details);
984
+ this.pageStores.set(tabId, pageStore);
985
+ this.pageStoresToken = Date.now();
986
+ return pageStore;
987
+ }
988
+
989
+ // https://github.com/chrisaljoudi/uBlock/issues/516
990
+ // Never rebind behind-the-scene scope.
991
+ if ( vAPI.isBehindTheSceneTabId(tabId) ) {
992
+ return pageStore;
993
+ }
994
+
995
+ // https://github.com/chrisaljoudi/uBlock/issues/516
996
+ // If context is 'beforeRequest', do not rebind, wait for confirmation.
997
+ if ( context === 'beforeRequest' ) {
998
+ pageStore.netFilteringCache.empty();
999
+ return pageStore;
1000
+ }
1001
+
1002
+ // Rebind according to context. We rebind even if the URL did not change,
1003
+ // as maybe the tab was force-reloaded, in which case the page stats must
1004
+ // be all reset.
1005
+ pageStore.reuse(context, details);
1006
+
1007
+ this.pageStoresToken = Date.now();
1008
+
1009
+ return pageStore;
1010
+ };
1011
+
1012
+ /******************************************************************************/
1013
+
1014
+ µb.unbindTabFromPageStore = function(tabId) {
1015
+ const pageStore = this.pageStores.get(tabId);
1016
+ if ( pageStore === undefined ) { return; }
1017
+ pageStore.dispose();
1018
+ this.pageStores.delete(tabId);
1019
+ this.pageStoresToken = Date.now();
1020
+ };
1021
+
1022
+ /******************************************************************************/
1023
+
1024
+ µb.pageStoreFromTabId = function(tabId) {
1025
+ return this.pageStores.get(tabId) || null;
1026
+ };
1027
+
1028
+ µb.mustPageStoreFromTabId = function(tabId) {
1029
+ return this.pageStores.get(tabId) || this.pageStores.get(vAPI.noTabId);
1030
+ };
1031
+
1032
+ /******************************************************************************/
1033
+
1034
+ // Permanent page store for behind-the-scene requests. Must never be removed.
1035
+ //
1036
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/651
1037
+ // The whitelist status of the tabless page store will be determined by
1038
+ // the document context (if present) of the network request.
1039
+
1040
+ {
1041
+ const NoPageStore = class extends PageStore {
1042
+ getNetFilteringSwitch(fctxt) {
1043
+ if ( fctxt ) {
1044
+ const docOrigin = fctxt.getDocOrigin();
1045
+ if ( docOrigin ) {
1046
+ return µb.getNetFilteringSwitch(docOrigin);
1047
+ }
1048
+ }
1049
+ return super.getNetFilteringSwitch();
1050
+ }
1051
+ };
1052
+ const pageStore = new NoPageStore(vAPI.noTabId);
1053
+ µb.pageStores.set(pageStore.tabId, pageStore);
1054
+ pageStore.title = i18n$('logBehindTheScene');
1055
+ }
1056
+
1057
+ /******************************************************************************/
1058
+
1059
+ // Update visual of extension icon.
1060
+
1061
+ {
1062
+ const tabIdToDetails = new Map();
1063
+
1064
+ const computeBadgeColor = (bits) => {
1065
+ let color = µb.blockingProfileColorCache.get(bits);
1066
+ if ( color !== undefined ) { return color; }
1067
+ let max = 0;
1068
+ for ( const profile of µb.liveBlockingProfiles ) {
1069
+ const v = bits & (profile.bits & ~1);
1070
+ if ( v < max ) { break; }
1071
+ color = profile.color;
1072
+ max = v;
1073
+ }
1074
+ if ( color === undefined ) {
1075
+ color = '#666';
1076
+ }
1077
+ µb.blockingProfileColorCache.set(bits, color);
1078
+ return color;
1079
+ };
1080
+
1081
+ const updateBadge = (tabId) => {
1082
+ let parts = tabIdToDetails.get(tabId);
1083
+ tabIdToDetails.delete(tabId);
1084
+
1085
+ let state = 0;
1086
+ let badge = '';
1087
+ let color = '#666';
1088
+
1089
+ const pageStore = µb.pageStoreFromTabId(tabId);
1090
+ if ( pageStore !== null ) {
1091
+ state = pageStore.getNetFilteringSwitch() ? 1 : 0;
1092
+ if ( state === 1 ) {
1093
+ if ( (parts & 0b0010) !== 0 ) {
1094
+ const blockCount = pageStore.counts.blocked.any;
1095
+ if ( blockCount !== 0 ) {
1096
+ badge = µb.formatCount(blockCount);
1097
+ }
1098
+ }
1099
+ if ( (parts & 0b0100) !== 0 ) {
1100
+ color = computeBadgeColor(
1101
+ µb.blockingModeFromHostname(pageStore.tabHostname)
1102
+ );
1103
+ }
1104
+ }
1105
+ }
1106
+
1107
+ // https://www.reddit.com/r/uBlockOrigin/comments/d33d37/
1108
+ if ( µb.userSettings.showIconBadge === false ) {
1109
+ parts |= 0b1000;
1110
+ }
1111
+
1112
+ vAPI.setIcon(tabId, { parts, state, badge, color });
1113
+ };
1114
+
1115
+ // parts: bit 0 = icon
1116
+ // bit 1 = badge text
1117
+ // bit 2 = badge color
1118
+ // bit 3 = hide badge
1119
+
1120
+ µb.updateToolbarIcon = function(tabId, newParts = 0b0111) {
1121
+ if ( this.readyToFilter === false ) { return; }
1122
+ if ( typeof tabId !== 'number' ) { return; }
1123
+ if ( vAPI.isBehindTheSceneTabId(tabId) ) { return; }
1124
+ const currentParts = tabIdToDetails.get(tabId);
1125
+ if ( currentParts === newParts ) { return; }
1126
+ if ( currentParts === undefined ) {
1127
+ self.requestIdleCallback(
1128
+ ( ) => updateBadge(tabId),
1129
+ { timeout: 701 }
1130
+ );
1131
+ } else {
1132
+ newParts |= currentParts;
1133
+ }
1134
+ tabIdToDetails.set(tabId, newParts);
1135
+ };
1136
+ }
1137
+
1138
+ /******************************************************************************/
1139
+
1140
+ // https://github.com/chrisaljoudi/uBlock/issues/455
1141
+ // Stale page store entries janitor
1142
+
1143
+ {
1144
+ let pageStoreJanitorSampleAt = 0;
1145
+ let pageStoreJanitorSampleSize = 10;
1146
+
1147
+ const checkTab = async tabId => {
1148
+ const tab = await vAPI.tabs.get(tabId);
1149
+ if ( tab instanceof Object && tab.discarded !== true ) { return; }
1150
+ µb.unbindTabFromPageStore(tabId);
1151
+ };
1152
+
1153
+ const pageStoreJanitor = function() {
1154
+ const tabIds = Array.from(µb.pageStores.keys()).sort();
1155
+ if ( pageStoreJanitorSampleAt >= tabIds.length ) {
1156
+ pageStoreJanitorSampleAt = 0;
1157
+ }
1158
+ const n = Math.min(
1159
+ pageStoreJanitorSampleAt + pageStoreJanitorSampleSize,
1160
+ tabIds.length
1161
+ );
1162
+ for ( let i = pageStoreJanitorSampleAt; i < n; i++ ) {
1163
+ const tabId = tabIds[i];
1164
+ if ( vAPI.isBehindTheSceneTabId(tabId) ) { continue; }
1165
+ checkTab(tabId);
1166
+ }
1167
+ pageStoreJanitorSampleAt = n;
1168
+
1169
+ pageStoreJanitorTimer.on(pageStoreJanitorPeriod);
1170
+ };
1171
+
1172
+ const pageStoreJanitorTimer = vAPI.defer.create(pageStoreJanitor);
1173
+ const pageStoreJanitorPeriod = { min: 15 };
1174
+
1175
+ pageStoreJanitorTimer.on(pageStoreJanitorPeriod);
1176
+ }
1177
+
1178
+ /******************************************************************************/