@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,1365 @@
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
+ /* global CSS */
23
+
24
+ 'use strict';
25
+
26
+ /******************************************************************************/
27
+ /******************************************************************************/
28
+
29
+ (async ( ) => {
30
+
31
+ /******************************************************************************/
32
+
33
+ if ( typeof vAPI !== 'object' || vAPI === null ) {
34
+ return;
35
+ }
36
+
37
+ /******************************************************************************/
38
+
39
+ const epickerId = vAPI.randomToken();
40
+ let epickerConnectionId;
41
+
42
+ let pickerRoot = document.querySelector(`[${vAPI.sessionId}]`);
43
+ if ( pickerRoot !== null ) { return; }
44
+
45
+ let pickerBootArgs;
46
+
47
+ const reCosmeticAnchor = /^#(\$|\?|\$\?)?#/;
48
+
49
+ const netFilterCandidates = [];
50
+ const cosmeticFilterCandidates = [];
51
+
52
+ let targetElements = [];
53
+ let candidateElements = [];
54
+ let bestCandidateFilter = null;
55
+
56
+ const lastNetFilterSession = window.location.host + window.location.pathname;
57
+ let lastNetFilterHostname = '';
58
+ let lastNetFilterUnion = '';
59
+
60
+ const hideBackgroundStyle = 'background-image:none!important;';
61
+
62
+ /******************************************************************************/
63
+
64
+ const safeQuerySelectorAll = function(node, selector) {
65
+ if ( node !== null ) {
66
+ try {
67
+ return node.querySelectorAll(selector);
68
+ } catch (e) {
69
+ }
70
+ }
71
+ return [];
72
+ };
73
+
74
+ /******************************************************************************/
75
+
76
+ const getElementBoundingClientRect = function(elem) {
77
+ let rect = typeof elem.getBoundingClientRect === 'function'
78
+ ? elem.getBoundingClientRect()
79
+ : { height: 0, left: 0, top: 0, width: 0 };
80
+
81
+ // https://github.com/gorhill/uBlock/issues/1024
82
+ // Try not returning an empty bounding rect.
83
+ if ( rect.width !== 0 && rect.height !== 0 ) {
84
+ return rect;
85
+ }
86
+ if ( elem.shadowRoot instanceof DocumentFragment ) {
87
+ return getElementBoundingClientRect(elem.shadowRoot);
88
+ }
89
+
90
+ let left = rect.left,
91
+ right = left + rect.width,
92
+ top = rect.top,
93
+ bottom = top + rect.height;
94
+
95
+ for ( const child of elem.children ) {
96
+ rect = getElementBoundingClientRect(child);
97
+ if ( rect.width === 0 || rect.height === 0 ) { continue; }
98
+ if ( rect.left < left ) { left = rect.left; }
99
+ if ( rect.right > right ) { right = rect.right; }
100
+ if ( rect.top < top ) { top = rect.top; }
101
+ if ( rect.bottom > bottom ) { bottom = rect.bottom; }
102
+ }
103
+
104
+ return {
105
+ bottom,
106
+ height: bottom - top,
107
+ left,
108
+ right,
109
+ top,
110
+ width: right - left
111
+ };
112
+ };
113
+
114
+ /******************************************************************************/
115
+
116
+ const highlightElements = function(elems, force) {
117
+ // To make mouse move handler more efficient
118
+ if (
119
+ (force !== true) &&
120
+ (elems.length === targetElements.length) &&
121
+ (elems.length === 0 || elems[0] === targetElements[0])
122
+ ) {
123
+ return;
124
+ }
125
+ targetElements = [];
126
+
127
+ const ow = self.innerWidth;
128
+ const oh = self.innerHeight;
129
+ const islands = [];
130
+
131
+ for ( const elem of elems ) {
132
+ if ( elem === pickerRoot ) { continue; }
133
+ targetElements.push(elem);
134
+ const rect = getElementBoundingClientRect(elem);
135
+ // Ignore offscreen areas
136
+ if (
137
+ rect.left > ow || rect.top > oh ||
138
+ rect.left + rect.width < 0 || rect.top + rect.height < 0
139
+ ) {
140
+ continue;
141
+ }
142
+ islands.push(
143
+ `M${rect.left} ${rect.top}h${rect.width}v${rect.height}h-${rect.width}z`
144
+ );
145
+ }
146
+
147
+ vAPI.MessagingConnection.sendTo(epickerConnectionId, {
148
+ what: 'svgPaths',
149
+ ocean: `M0 0h${ow}v${oh}h-${ow}z`,
150
+ islands: islands.join(''),
151
+ });
152
+ };
153
+
154
+ /******************************************************************************/
155
+
156
+ const mergeStrings = function(urls) {
157
+ if ( urls.length === 0 ) { return ''; }
158
+ if (
159
+ urls.length === 1 ||
160
+ self.diff_match_patch instanceof Function === false
161
+ ) {
162
+ return urls[0];
163
+ }
164
+ const differ = new self.diff_match_patch();
165
+ let merged = urls[0];
166
+ for ( let i = 1; i < urls.length; i++ ) {
167
+ // The differ works at line granularity: we insert a linefeed after
168
+ // each character to trick the differ to work at character granularity.
169
+ const diffs = differ.diff_main(
170
+ urls[i].split('').join('\n'),
171
+ merged.split('').join('\n')
172
+ );
173
+ const result = [];
174
+ for ( const diff of diffs ) {
175
+ if ( diff[0] !== 0 ) {
176
+ result.push('*');
177
+ } else {
178
+ result.push(diff[1].replace(/\n+/g, ''));
179
+ }
180
+ merged = result.join('');
181
+ }
182
+ }
183
+ // Keep usage of wildcards to a sane level, too many of them can cause
184
+ // high overhead filters
185
+ merged = merged.replace(/^\*+$/, '')
186
+ .replace(/\*{2,}/g, '*')
187
+ .replace(/([^*]{1,3}\*)(?:[^*]{1,3}\*)+/g, '$1');
188
+
189
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/1494
190
+ let pos = merged.indexOf('/');
191
+ if ( pos === -1 ) { pos = merged.length; }
192
+ return merged.slice(0, pos).includes('*') ? urls[0] : merged;
193
+ };
194
+
195
+ /******************************************************************************/
196
+
197
+ // Remove fragment part from a URL.
198
+
199
+ const trimFragmentFromURL = function(url) {
200
+ const pos = url.indexOf('#');
201
+ return pos !== -1 ? url.slice(0, pos) : url;
202
+ };
203
+
204
+ /******************************************************************************/
205
+
206
+ // https://github.com/gorhill/uBlock/issues/1897
207
+ // Ignore `data:` URI, they can't be handled by an HTTP observer.
208
+
209
+ const backgroundImageURLFromElement = function(elem) {
210
+ const style = window.getComputedStyle(elem);
211
+ const bgImg = style.backgroundImage || '';
212
+ const matches = /^url\((["']?)([^"']+)\1\)$/.exec(bgImg);
213
+ const url = matches !== null && matches.length === 3 ? matches[2] : '';
214
+ return url.lastIndexOf('data:', 0) === -1
215
+ ? trimFragmentFromURL(url.slice(0, 1024))
216
+ : '';
217
+ };
218
+
219
+ /******************************************************************************/
220
+
221
+ // https://github.com/gorhill/uBlock/issues/1725#issuecomment-226479197
222
+ // Limit returned string to 1024 characters.
223
+ // Also, return only URLs which will be seen by an HTTP observer.
224
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/2260
225
+ // Maybe get to the actual URL indirectly.
226
+ const resourceURLsFromElement = function(elem) {
227
+ const urls = [];
228
+ const tagName = elem.localName;
229
+ const prop = netFilter1stSources[tagName];
230
+ if ( prop === undefined ) {
231
+ const url = backgroundImageURLFromElement(elem);
232
+ if ( url !== '' ) { urls.push(url); }
233
+ return urls;
234
+ }
235
+ let s = elem[prop];
236
+ if ( s instanceof SVGAnimatedString ) {
237
+ s = s.baseVal;
238
+ }
239
+ if ( typeof s === 'string' && /^https?:\/\//.test(s) ) {
240
+ urls.push(trimFragmentFromURL(s.slice(0, 1024)));
241
+ }
242
+ resourceURLsFromSrcset(elem, urls);
243
+ resourceURLsFromPicture(elem, urls);
244
+ return urls;
245
+ };
246
+
247
+ // https://html.spec.whatwg.org/multipage/images.html#parsing-a-srcset-attribute
248
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/1071
249
+ const resourceURLsFromSrcset = function(elem, out) {
250
+ let srcset = elem.srcset;
251
+ if ( typeof srcset !== 'string' || srcset === '' ) { return; }
252
+ for(;;) {
253
+ // trim whitespace
254
+ srcset = srcset.trim();
255
+ if ( srcset.length === 0 ) { break; }
256
+ // abort in case of leading comma
257
+ if ( /^,/.test(srcset) ) { break; }
258
+ // collect and consume all non-whitespace characters
259
+ let match = /^\S+/.exec(srcset);
260
+ if ( match === null ) { break; }
261
+ srcset = srcset.slice(match.index + match[0].length);
262
+ let url = match[0];
263
+ // consume descriptor, if any
264
+ if ( /,$/.test(url) ) {
265
+ url = url.replace(/,$/, '');
266
+ if ( /,$/.test(url) ) { break; }
267
+ } else {
268
+ match = /^[^,]*(?:\(.+?\))?[^,]*(?:,|$)/.exec(srcset);
269
+ if ( match === null ) { break; }
270
+ srcset = srcset.slice(match.index + match[0].length);
271
+ }
272
+ const parsedURL = new URL(url, document.baseURI);
273
+ if ( parsedURL.pathname.length === 0 ) { continue; }
274
+ out.push(trimFragmentFromURL(parsedURL.href));
275
+ }
276
+ };
277
+
278
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/2069#issuecomment-1080600661
279
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture
280
+ const resourceURLsFromPicture = function(elem, out) {
281
+ if ( elem.localName === 'source' ) { return; }
282
+ const picture = elem.parentElement;
283
+ if ( picture === null || picture.localName !== 'picture' ) { return; }
284
+ const sources = picture.querySelectorAll(':scope > source');
285
+ for ( const source of sources ) {
286
+ const urls = resourceURLsFromElement(source);
287
+ if ( urls.length === 0 ) { continue; }
288
+ out.push(...urls);
289
+ }
290
+ };
291
+
292
+ /******************************************************************************/
293
+
294
+ const netFilterFromUnion = function(patternIn, out) {
295
+ // Reset reference filter when dealing with unrelated URLs
296
+ const currentHostname = self.location.hostname;
297
+ if (
298
+ lastNetFilterUnion === '' ||
299
+ currentHostname === '' ||
300
+ currentHostname !== lastNetFilterHostname
301
+ ) {
302
+ lastNetFilterHostname = currentHostname;
303
+ lastNetFilterUnion = patternIn;
304
+ vAPI.messaging.send('elementPicker', {
305
+ what: 'elementPickerEprom',
306
+ lastNetFilterSession,
307
+ lastNetFilterHostname,
308
+ lastNetFilterUnion,
309
+ });
310
+ return;
311
+ }
312
+
313
+ // Related URLs
314
+ lastNetFilterHostname = currentHostname;
315
+ let patternOut = mergeStrings([ patternIn, lastNetFilterUnion ]);
316
+ if ( patternOut !== '/*' && patternOut !== patternIn ) {
317
+ const filter = `||${patternOut}`;
318
+ if ( out.indexOf(filter) === -1 ) {
319
+ out.push(filter);
320
+ }
321
+ lastNetFilterUnion = patternOut;
322
+ }
323
+
324
+ // Remember across element picker sessions
325
+ vAPI.messaging.send('elementPicker', {
326
+ what: 'elementPickerEprom',
327
+ lastNetFilterSession,
328
+ lastNetFilterHostname,
329
+ lastNetFilterUnion,
330
+ });
331
+ };
332
+
333
+ /******************************************************************************/
334
+
335
+ // Extract the best possible net filter, i.e. as specific as possible.
336
+
337
+ const netFilterFromElement = function(elem) {
338
+ if ( elem === null ) { return 0; }
339
+ if ( elem.nodeType !== 1 ) { return 0; }
340
+ const urls = resourceURLsFromElement(elem);
341
+ if ( urls.length === 0 ) { return 0; }
342
+
343
+ if ( candidateElements.indexOf(elem) === -1 ) {
344
+ candidateElements.push(elem);
345
+ }
346
+
347
+ const candidates = netFilterCandidates;
348
+ const len = candidates.length;
349
+
350
+ for ( let i = 0; i < urls.length; i++ ) {
351
+ urls[i] = urls[i].replace(/^https?:\/\//, '');
352
+ }
353
+ const pattern = mergeStrings(urls);
354
+
355
+
356
+ if ( bestCandidateFilter === null && elem.matches('html,body') === false ) {
357
+ bestCandidateFilter = {
358
+ type: 'net',
359
+ filters: candidates,
360
+ slot: candidates.length
361
+ };
362
+ }
363
+
364
+ candidates.push(`||${pattern}`);
365
+
366
+ // Suggest a less narrow filter if possible
367
+ const pos = pattern.indexOf('?');
368
+ if ( pos !== -1 ) {
369
+ candidates.push(`||${pattern.slice(0, pos)}`);
370
+ }
371
+
372
+ // Suggest a filter which is a result of combining more than one URL.
373
+ netFilterFromUnion(pattern, candidates);
374
+
375
+ return candidates.length - len;
376
+ };
377
+
378
+ const netFilter1stSources = {
379
+ 'audio': 'src',
380
+ 'embed': 'src',
381
+ 'iframe': 'src',
382
+ 'img': 'src',
383
+ 'image': 'href',
384
+ 'object': 'data',
385
+ 'source': 'src',
386
+ 'video': 'src'
387
+ };
388
+
389
+ const filterTypes = {
390
+ 'audio': 'media',
391
+ 'embed': 'object',
392
+ 'iframe': 'subdocument',
393
+ 'img': 'image',
394
+ 'object': 'object',
395
+ 'video': 'media',
396
+ };
397
+
398
+ /******************************************************************************/
399
+
400
+ // Extract the best possible cosmetic filter, i.e. as specific as possible.
401
+
402
+ // https://github.com/gorhill/uBlock/issues/1725
403
+ // Also take into account the `src` attribute for `img` elements -- and limit
404
+ // the value to the 1024 first characters.
405
+
406
+ const cosmeticFilterFromElement = function(elem) {
407
+ if ( elem === null ) { return 0; }
408
+ if ( elem.nodeType !== 1 ) { return 0; }
409
+ if ( noCosmeticFiltering ) { return 0; }
410
+
411
+ if ( candidateElements.indexOf(elem) === -1 ) {
412
+ candidateElements.push(elem);
413
+ }
414
+
415
+ let selector = '';
416
+
417
+ // Id
418
+ let v = typeof elem.id === 'string' && CSS.escape(elem.id);
419
+ if ( v ) {
420
+ selector = '#' + v;
421
+ }
422
+
423
+ // Class(es)
424
+ v = elem.classList;
425
+ if ( v ) {
426
+ let i = v.length || 0;
427
+ while ( i-- ) {
428
+ selector += '.' + CSS.escape(v.item(i));
429
+ }
430
+ }
431
+
432
+ // Tag name
433
+ const tagName = CSS.escape(elem.localName);
434
+
435
+ // Use attributes if still no selector found.
436
+ // https://github.com/gorhill/uBlock/issues/1901
437
+ // Trim attribute value, this may help in case of malformed HTML.
438
+ //
439
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/1923
440
+ // Escape unescaped `"` in attribute values
441
+ if ( selector === '' ) {
442
+ let attributes = [], attr;
443
+ switch ( tagName ) {
444
+ case 'a':
445
+ v = elem.getAttribute('href');
446
+ if ( v ) {
447
+ v = v.trim().replace(/\?.*$/, '');
448
+ if ( v.length ) {
449
+ attributes.push({ k: 'href', v: v });
450
+ }
451
+ }
452
+ break;
453
+ case 'iframe':
454
+ case 'img':
455
+ v = elem.getAttribute('src');
456
+ if ( v && v.length !== 0 ) {
457
+ v = v.trim();
458
+ if ( v.startsWith('data:') ) {
459
+ let pos = v.indexOf(',');
460
+ if ( pos !== -1 ) {
461
+ v = v.slice(0, pos + 1);
462
+ }
463
+ } else if ( v.startsWith('blob:') ) {
464
+ v = new URL(v.slice(5));
465
+ v.pathname = '';
466
+ v = 'blob:' + v.href;
467
+ }
468
+ attributes.push({ k: 'src', v: v.slice(0, 256) });
469
+ break;
470
+ }
471
+ v = elem.getAttribute('alt');
472
+ if ( v && v.length !== 0 ) {
473
+ attributes.push({ k: 'alt', v: v });
474
+ break;
475
+ }
476
+ break;
477
+ default:
478
+ break;
479
+ }
480
+ while ( (attr = attributes.pop()) ) {
481
+ if ( attr.v.length === 0 ) { continue; }
482
+ const w = attr.v.replace(/([^\\])"/g, '$1\\"');
483
+ v = elem.getAttribute(attr.k);
484
+ if ( attr.v === v ) {
485
+ selector += `[${attr.k}="${w}"]`;
486
+ } else if ( v.startsWith(attr.v) ) {
487
+ selector += `[${attr.k}^="${w}"]`;
488
+ } else {
489
+ selector += `[${attr.k}*="${w}"]`;
490
+ }
491
+ }
492
+ }
493
+
494
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/17
495
+ // If selector is ambiguous at this point, add the element name to
496
+ // further narrow it down.
497
+ const parentNode = elem.parentNode;
498
+ if (
499
+ selector === '' ||
500
+ safeQuerySelectorAll(parentNode, `:scope > ${selector}`).length > 1
501
+ ) {
502
+ selector = tagName + selector;
503
+ }
504
+
505
+ // https://github.com/chrisaljoudi/uBlock/issues/637
506
+ // If the selector is still ambiguous at this point, further narrow using
507
+ // `nth-of-type`. It is preferable to use `nth-of-type` as opposed to
508
+ // `nth-child`, as `nth-of-type` is less volatile.
509
+ if ( safeQuerySelectorAll(parentNode, `:scope > ${selector}`).length > 1 ) {
510
+ let i = 1;
511
+ while ( elem.previousSibling !== null ) {
512
+ elem = elem.previousSibling;
513
+ if (
514
+ typeof elem.localName === 'string' &&
515
+ elem.localName === tagName
516
+ ) {
517
+ i++;
518
+ }
519
+ }
520
+ selector += `:nth-of-type(${i})`;
521
+ }
522
+
523
+ if ( bestCandidateFilter === null ) {
524
+ bestCandidateFilter = {
525
+ type: 'cosmetic',
526
+ filters: cosmeticFilterCandidates,
527
+ slot: cosmeticFilterCandidates.length
528
+ };
529
+ }
530
+
531
+ cosmeticFilterCandidates.push(`##${selector}`);
532
+
533
+ return 1;
534
+ };
535
+
536
+ /******************************************************************************/
537
+
538
+ const filtersFrom = function(x, y) {
539
+ bestCandidateFilter = null;
540
+ netFilterCandidates.length = 0;
541
+ cosmeticFilterCandidates.length = 0;
542
+ candidateElements.length = 0;
543
+
544
+ // We need at least one element.
545
+ let first = null;
546
+ if ( typeof x === 'number' ) {
547
+ first = elementFromPoint(x, y);
548
+ } else if ( x instanceof HTMLElement ) {
549
+ first = x;
550
+ x = undefined;
551
+ }
552
+
553
+ // https://github.com/gorhill/uBlock/issues/1545
554
+ // Network filter candidates from all other elements found at [x,y].
555
+ // https://www.reddit.com/r/uBlockOrigin/comments/qmjk36/
556
+ // Extract network candidates first.
557
+ if ( typeof x === 'number' ) {
558
+ const magicAttr = `${vAPI.sessionId}-clickblind`;
559
+ pickerRoot.setAttribute(magicAttr, '');
560
+ const elems = document.elementsFromPoint(x, y);
561
+ pickerRoot.removeAttribute(magicAttr);
562
+ for ( const elem of elems ) {
563
+ netFilterFromElement(elem);
564
+ }
565
+ } else if ( first !== null ) {
566
+ netFilterFromElement(first);
567
+ }
568
+
569
+ // Cosmetic filter candidates from ancestors.
570
+ // https://github.com/gorhill/uBlock/issues/2519
571
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/17
572
+ // Prepend `body` if full selector is ambiguous.
573
+ let elem = first;
574
+ while ( elem && elem !== document.body ) {
575
+ cosmeticFilterFromElement(elem);
576
+ elem = elem.parentNode;
577
+ }
578
+ // The body tag is needed as anchor only when the immediate child
579
+ // uses `nth-of-type`.
580
+ let i = cosmeticFilterCandidates.length;
581
+ if ( i !== 0 ) {
582
+ const selector = cosmeticFilterCandidates[i-1].slice(2);
583
+ if ( safeQuerySelectorAll(document.body, selector).length > 1 ) {
584
+ cosmeticFilterCandidates.push('##body');
585
+ }
586
+ }
587
+
588
+ // https://github.com/gorhill/uBlock/commit/ebaa8a8bb28aef043a68c99965fe6c128a3fe5e4#commitcomment-63818019
589
+ // If still no best candidate, just use whatever is available in network
590
+ // filter candidates -- which may have been previously skipped in favor
591
+ // of cosmetic filters.
592
+ if ( bestCandidateFilter === null && netFilterCandidates.length !== 0 ) {
593
+ bestCandidateFilter = {
594
+ type: 'net',
595
+ filters: netFilterCandidates,
596
+ slot: 0
597
+ };
598
+ }
599
+
600
+ return netFilterCandidates.length + cosmeticFilterCandidates.length;
601
+ };
602
+
603
+ /*******************************************************************************
604
+
605
+ filterToDOMInterface.queryAll
606
+ @desc Look-up all the HTML elements matching the filter passed in
607
+ argument.
608
+ @param string, a cosmetic or network filter.
609
+ @param function, called once all items matching the filter have been
610
+ collected.
611
+ @return array, or undefined if the filter is invalid.
612
+
613
+ filterToDOMInterface.preview
614
+ @desc Apply/unapply filter to the DOM.
615
+ @param string, a cosmetic of network filter, or literal false to remove
616
+ the effects of the filter on the DOM.
617
+ @return undefined.
618
+
619
+ TODO: need to be revised once I implement chained cosmetic operators.
620
+
621
+ */
622
+
623
+ const filterToDOMInterface = (( ) => {
624
+ const reHnAnchorPrefix = '^[\\w-]+://(?:[^/?#]+\\.)?';
625
+ const reCaret = '(?:[^%.0-9a-z_-]|$)';
626
+ const rePseudoElements = /:(?::?after|:?before|:[a-z-]+)$/;
627
+
628
+ // Net filters: we need to lookup manually -- translating into a foolproof
629
+ // CSS selector is just not possible.
630
+ //
631
+ // https://github.com/chrisaljoudi/uBlock/issues/945
632
+ // Transform into a regular expression, this allows the user to
633
+ // edit and insert wildcard(s) into the proposed filter.
634
+ // https://www.reddit.com/r/uBlockOrigin/comments/c5do7w/
635
+ // Better handling of pure hostname filters. Also, discard single
636
+ // alphanumeric character filters.
637
+ const fromNetworkFilter = function(filter) {
638
+ const out = [];
639
+ if ( /^[0-9a-z]$/i.test(filter) ) { return out; }
640
+ let reStr = '';
641
+ if (
642
+ filter.length > 2 &&
643
+ filter.startsWith('/') &&
644
+ filter.endsWith('/')
645
+ ) {
646
+ reStr = filter.slice(1, -1);
647
+ } else if ( /^\w[\w.-]*[a-z]$/i.test(filter) ) {
648
+ reStr = reHnAnchorPrefix +
649
+ filter.toLowerCase().replace(/\./g, '\\.') +
650
+ reCaret;
651
+ } else {
652
+ let rePrefix = '', reSuffix = '';
653
+ if ( filter.startsWith('||') ) {
654
+ rePrefix = reHnAnchorPrefix;
655
+ filter = filter.slice(2);
656
+ } else if ( filter.startsWith('|') ) {
657
+ rePrefix = '^';
658
+ filter = filter.slice(1);
659
+ }
660
+ if ( filter.endsWith('|') ) {
661
+ reSuffix = '$';
662
+ filter = filter.slice(0, -1);
663
+ }
664
+ reStr = rePrefix +
665
+ filter.replace(/[.+?${}()|[\]\\]/g, '\\$&')
666
+ .replace(/\*+/g, '.*')
667
+ .replace(/\^/g, reCaret) +
668
+ reSuffix;
669
+ }
670
+ let reFilter = null;
671
+ try {
672
+ reFilter = new RegExp(reStr, 'i');
673
+ }
674
+ catch (e) {
675
+ return out;
676
+ }
677
+
678
+ // Lookup by tag names.
679
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/2260
680
+ // Maybe get to the actual URL indirectly.
681
+ const elems = document.querySelectorAll(
682
+ Object.keys(netFilter1stSources).join()
683
+ );
684
+ for ( const elem of elems ) {
685
+ const srcProp = netFilter1stSources[elem.localName];
686
+ let src = elem[srcProp];
687
+ if ( src instanceof SVGAnimatedString ) {
688
+ src = src.baseVal;
689
+ }
690
+ if (
691
+ typeof src === 'string' &&
692
+ reFilter.test(src) ||
693
+ typeof elem.currentSrc === 'string' &&
694
+ reFilter.test(elem.currentSrc)
695
+ ) {
696
+ out.push({
697
+ elem,
698
+ src: srcProp,
699
+ opt: filterTypes[elem.localName],
700
+ style: vAPI.hideStyle,
701
+ });
702
+ }
703
+ }
704
+
705
+ // Find matching background image in current set of candidate elements.
706
+ for ( const elem of candidateElements ) {
707
+ if ( reFilter.test(backgroundImageURLFromElement(elem)) ) {
708
+ out.push({
709
+ elem,
710
+ bg: true,
711
+ opt: 'image',
712
+ style: hideBackgroundStyle,
713
+ });
714
+ }
715
+ }
716
+
717
+ return out;
718
+ };
719
+
720
+ // Cosmetic filters: these are straight CSS selectors.
721
+ //
722
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/389
723
+ // Test filter using comma-separated list to better detect invalid CSS
724
+ // selectors.
725
+ //
726
+ // https://github.com/gorhill/uBlock/issues/2515
727
+ // Remove trailing pseudo-element when querying.
728
+ const fromPlainCosmeticFilter = function(raw) {
729
+ let elems;
730
+ try {
731
+ document.documentElement.matches(`${raw},\na`);
732
+ elems = document.querySelectorAll(
733
+ raw.replace(rePseudoElements, '')
734
+ );
735
+ }
736
+ catch (e) {
737
+ return;
738
+ }
739
+ const out = [];
740
+ for ( const elem of elems ) {
741
+ if ( elem === pickerRoot ) { continue; }
742
+ out.push({ elem, raw, style: vAPI.hideStyle });
743
+ }
744
+ return out;
745
+ };
746
+
747
+ // https://github.com/gorhill/uBlock/issues/1772
748
+ // Handle procedural cosmetic filters.
749
+ //
750
+ // https://github.com/gorhill/uBlock/issues/2515
751
+ // Remove trailing pseudo-element when querying.
752
+ const fromCompiledCosmeticFilter = function(raw) {
753
+ if ( noCosmeticFiltering ) { return; }
754
+ if ( typeof raw !== 'string' ) { return; }
755
+ let elems, style;
756
+ try {
757
+ const o = JSON.parse(raw);
758
+ elems = vAPI.domFilterer.createProceduralFilter(o).exec();
759
+ switch ( o.action && o.action[0] || '' ) {
760
+ case '':
761
+ case 'remove':
762
+ style = vAPI.hideStyle;
763
+ break;
764
+ case 'style':
765
+ style = o.action[1];
766
+ break;
767
+ default:
768
+ break;
769
+ }
770
+ } catch(ex) {
771
+ return;
772
+ }
773
+ if ( !elems ) { return; }
774
+ const out = [];
775
+ for ( const elem of elems ) {
776
+ out.push({ elem, raw, style });
777
+ }
778
+ return out;
779
+ };
780
+
781
+ vAPI.epickerStyleProxies = vAPI.epickerStyleProxies || new Map();
782
+
783
+ let lastFilter;
784
+ let lastResultset;
785
+ let previewing = false;
786
+
787
+ const queryAll = function(details) {
788
+ let { filter, compiled } = details;
789
+ filter = filter.trim();
790
+ if ( filter === lastFilter ) { return lastResultset; }
791
+ unapply();
792
+ if ( filter === '' || filter === '!' ) {
793
+ lastFilter = '';
794
+ lastResultset = undefined;
795
+ return;
796
+ }
797
+ lastFilter = filter;
798
+ if ( reCosmeticAnchor.test(filter) === false ) {
799
+ lastResultset = fromNetworkFilter(filter);
800
+ if ( previewing ) { apply(); }
801
+ return lastResultset;
802
+ }
803
+ lastResultset = fromPlainCosmeticFilter(compiled);
804
+ if ( lastResultset ) {
805
+ if ( previewing ) { apply(); }
806
+ return lastResultset;
807
+ }
808
+ // Procedural cosmetic filter
809
+ lastResultset = fromCompiledCosmeticFilter(compiled);
810
+ if ( previewing ) { apply(); }
811
+ return lastResultset;
812
+ };
813
+
814
+ const apply = function() {
815
+ unapply();
816
+ if ( Array.isArray(lastResultset) === false ) { return; }
817
+ const rootElem = document.documentElement;
818
+ for ( const { elem, style } of lastResultset ) {
819
+ if ( elem === pickerRoot ) { continue; }
820
+ if ( style === undefined ) { continue; }
821
+ if ( elem === rootElem && style === vAPI.hideStyle ) { continue; }
822
+ let styleToken = vAPI.epickerStyleProxies.get(style);
823
+ if ( styleToken === undefined ) {
824
+ styleToken = vAPI.randomToken();
825
+ vAPI.epickerStyleProxies.set(style, styleToken);
826
+ vAPI.userStylesheet.add(`[${styleToken}]\n{${style}}`, true);
827
+ }
828
+ elem.setAttribute(styleToken, '');
829
+ }
830
+ };
831
+
832
+ const unapply = function() {
833
+ for ( const styleToken of vAPI.epickerStyleProxies.values() ) {
834
+ for ( const elem of document.querySelectorAll(`[${styleToken}]`) ) {
835
+ elem.removeAttribute(styleToken);
836
+ }
837
+ }
838
+ };
839
+
840
+ // https://www.reddit.com/r/uBlockOrigin/comments/c62irc/
841
+ // Support injecting the cosmetic filters into the DOM filterer
842
+ // immediately rather than wait for the next page load.
843
+ const preview = function(state, permanent = false) {
844
+ previewing = state !== false;
845
+ if ( previewing === false ) {
846
+ return unapply();
847
+ }
848
+ if ( Array.isArray(lastResultset) === false ) { return; }
849
+ if ( permanent === false || reCosmeticAnchor.test(lastFilter) === false ) {
850
+ return apply();
851
+ }
852
+ if ( noCosmeticFiltering ) { return; }
853
+ const cssSelectors = new Set();
854
+ const proceduralSelectors = new Set();
855
+ for ( const { raw } of lastResultset ) {
856
+ if ( raw.startsWith('{') ) {
857
+ proceduralSelectors.add(raw);
858
+ } else {
859
+ cssSelectors.add(raw);
860
+ }
861
+ }
862
+ if ( cssSelectors.size !== 0 ) {
863
+ vAPI.domFilterer.addCSS(
864
+ `${Array.from(cssSelectors).join('\n')}\n{${vAPI.hideStyle}}`,
865
+ { mustInject: true }
866
+ );
867
+ }
868
+ if ( proceduralSelectors.size !== 0 ) {
869
+ vAPI.domFilterer.addProceduralSelectors(
870
+ Array.from(proceduralSelectors)
871
+ );
872
+ }
873
+ };
874
+
875
+ return { preview, queryAll };
876
+ })();
877
+
878
+ /******************************************************************************/
879
+
880
+ const onOptimizeCandidates = function(details) {
881
+ const { candidates } = details;
882
+ const results = [];
883
+ for ( const paths of candidates ) {
884
+ let count = Number.MAX_SAFE_INTEGER;
885
+ let selector = '';
886
+ for ( let i = 0, n = paths.length; i < n; i++ ) {
887
+ const s = paths.slice(n - i - 1).join('');
888
+ const elems = document.querySelectorAll(s);
889
+ if ( elems.length < count ) {
890
+ selector = s;
891
+ count = elems.length;
892
+ }
893
+ }
894
+ results.push({ selector: `##${selector}`, count });
895
+ }
896
+ // Sort by most match count and shortest selector to least match count and
897
+ // longest selector.
898
+ results.sort((a, b) => {
899
+ const r = b.count - a.count;
900
+ if ( r !== 0 ) { return r; }
901
+ return a.selector.length - b.selector.length;
902
+ });
903
+ vAPI.MessagingConnection.sendTo(epickerConnectionId, {
904
+ what: 'candidatesOptimized',
905
+ candidates: results.map(a => a.selector),
906
+ slot: details.slot,
907
+ });
908
+ };
909
+
910
+ /******************************************************************************/
911
+
912
+ const showDialog = function(options) {
913
+ vAPI.MessagingConnection.sendTo(epickerConnectionId, {
914
+ what: 'showDialog',
915
+ url: self.location.href,
916
+ netFilters: netFilterCandidates,
917
+ cosmeticFilters: cosmeticFilterCandidates,
918
+ filter: bestCandidateFilter,
919
+ options,
920
+ });
921
+ };
922
+
923
+ /******************************************************************************/
924
+
925
+ const elementFromPoint = (( ) => {
926
+ let lastX, lastY;
927
+
928
+ return (x, y) => {
929
+ if ( x !== undefined ) {
930
+ lastX = x; lastY = y;
931
+ } else if ( lastX !== undefined ) {
932
+ x = lastX; y = lastY;
933
+ } else {
934
+ return null;
935
+ }
936
+ if ( !pickerRoot ) { return null; }
937
+ const magicAttr = `${vAPI.sessionId}-clickblind`;
938
+ pickerRoot.setAttribute(magicAttr, '');
939
+ let elem = document.elementFromPoint(x, y);
940
+ if (
941
+ elem === null || /* to skip following tests */
942
+ elem === document.body ||
943
+ elem === document.documentElement || (
944
+ pickerBootArgs.zap !== true &&
945
+ noCosmeticFiltering &&
946
+ resourceURLsFromElement(elem).length === 0
947
+ )
948
+ ) {
949
+ elem = null;
950
+ }
951
+ // https://github.com/uBlockOrigin/uBlock-issues/issues/380
952
+ pickerRoot.removeAttribute(magicAttr);
953
+ return elem;
954
+ };
955
+ })();
956
+
957
+ /******************************************************************************/
958
+
959
+ const highlightElementAtPoint = function(mx, my) {
960
+ const elem = elementFromPoint(mx, my);
961
+ highlightElements(elem ? [ elem ] : []);
962
+ };
963
+
964
+ /******************************************************************************/
965
+
966
+ const filterElementAtPoint = function(mx, my, broad) {
967
+ if ( filtersFrom(mx, my) === 0 ) { return; }
968
+ showDialog({ broad });
969
+ };
970
+
971
+ /******************************************************************************/
972
+
973
+ // https://www.reddit.com/r/uBlockOrigin/comments/bktxtb/scrolling_doesnt_work/emn901o
974
+ // Override 'fixed' position property on body element if present.
975
+
976
+ // With touch-driven devices, first highlight the element and remove only
977
+ // when tapping again the highlighted area.
978
+
979
+ const zapElementAtPoint = function(mx, my, options) {
980
+ if ( options.highlight ) {
981
+ const elem = elementFromPoint(mx, my);
982
+ if ( elem ) {
983
+ highlightElements([ elem ]);
984
+ }
985
+ return;
986
+ }
987
+
988
+ let elemToRemove = targetElements.length !== 0 && targetElements[0] || null;
989
+ if ( elemToRemove === null && mx !== undefined ) {
990
+ elemToRemove = elementFromPoint(mx, my);
991
+ }
992
+
993
+ if ( elemToRemove instanceof Element === false ) { return; }
994
+
995
+ const getStyleValue = (elem, prop) => {
996
+ const style = window.getComputedStyle(elem);
997
+ return style ? style[prop] : '';
998
+ };
999
+
1000
+ // Heuristic to detect scroll-locking: remove such lock when detected.
1001
+ let maybeScrollLocked = elemToRemove.shadowRoot instanceof DocumentFragment;
1002
+ if ( maybeScrollLocked === false ) {
1003
+ let elem = elemToRemove;
1004
+ do {
1005
+ maybeScrollLocked =
1006
+ parseInt(getStyleValue(elem, 'zIndex'), 10) >= 1000 ||
1007
+ getStyleValue(elem, 'position') === 'fixed';
1008
+ elem = elem.parentElement;
1009
+ } while ( elem !== null && maybeScrollLocked === false );
1010
+ }
1011
+ if ( maybeScrollLocked ) {
1012
+ const doc = document;
1013
+ if ( getStyleValue(doc.body, 'overflowY') === 'hidden' ) {
1014
+ doc.body.style.setProperty('overflow', 'auto', 'important');
1015
+ }
1016
+ if ( getStyleValue(doc.body, 'position') === 'fixed' ) {
1017
+ doc.body.style.setProperty('position', 'initial', 'important');
1018
+ }
1019
+ if ( getStyleValue(doc.documentElement, 'position') === 'fixed' ) {
1020
+ doc.documentElement.style.setProperty('position', 'initial', 'important');
1021
+ }
1022
+ if ( getStyleValue(doc.documentElement, 'overflowY') === 'hidden' ) {
1023
+ doc.documentElement.style.setProperty('overflow', 'auto', 'important');
1024
+ }
1025
+ }
1026
+ elemToRemove.remove();
1027
+ highlightElementAtPoint(mx, my);
1028
+ };
1029
+
1030
+ /******************************************************************************/
1031
+
1032
+ const onKeyPressed = function(ev) {
1033
+ // Delete
1034
+ if (
1035
+ (ev.key === 'Delete' || ev.key === 'Backspace') &&
1036
+ pickerBootArgs.zap
1037
+ ) {
1038
+ ev.stopPropagation();
1039
+ ev.preventDefault();
1040
+ zapElementAtPoint();
1041
+ return;
1042
+ }
1043
+ // Esc
1044
+ if ( ev.key === 'Escape' || ev.which === 27 ) {
1045
+ ev.stopPropagation();
1046
+ ev.preventDefault();
1047
+ filterToDOMInterface.preview(false);
1048
+ quitPicker();
1049
+ return;
1050
+ }
1051
+ };
1052
+
1053
+ /******************************************************************************/
1054
+
1055
+ // https://github.com/chrisaljoudi/uBlock/issues/190
1056
+ // May need to dynamically adjust the height of the overlay + new position
1057
+ // of highlighted elements.
1058
+
1059
+ const onViewportChanged = function() {
1060
+ highlightElements(targetElements, true);
1061
+ };
1062
+
1063
+ /******************************************************************************/
1064
+
1065
+ // Auto-select a specific target, if any, and if possible
1066
+
1067
+ const startPicker = function() {
1068
+ pickerRoot.focus();
1069
+
1070
+ self.addEventListener('scroll', onViewportChanged, { passive: true });
1071
+ self.addEventListener('resize', onViewportChanged, { passive: true });
1072
+ self.addEventListener('keydown', onKeyPressed, true);
1073
+
1074
+ // Try using mouse position
1075
+ if (
1076
+ pickerBootArgs.mouse &&
1077
+ vAPI.mouseClick instanceof Object &&
1078
+ typeof vAPI.mouseClick.x === 'number' &&
1079
+ vAPI.mouseClick.x > 0
1080
+ ) {
1081
+ if ( filtersFrom(vAPI.mouseClick.x, vAPI.mouseClick.y) !== 0 ) {
1082
+ return showDialog();
1083
+ }
1084
+ }
1085
+
1086
+ // No mouse position available, use suggested target
1087
+ const target = pickerBootArgs.target || '';
1088
+ const pos = target.indexOf('\t');
1089
+ if ( pos === -1 ) { return; }
1090
+
1091
+ const srcAttrMap = {
1092
+ 'a': 'href',
1093
+ 'audio': 'src',
1094
+ 'embed': 'src',
1095
+ 'iframe': 'src',
1096
+ 'img': 'src',
1097
+ 'video': 'src',
1098
+ };
1099
+ const tagName = target.slice(0, pos);
1100
+ const url = target.slice(pos + 1);
1101
+ const attr = srcAttrMap[tagName];
1102
+ if ( attr === undefined ) { return; }
1103
+ const elems = document.getElementsByTagName(tagName);
1104
+ for ( const elem of elems ) {
1105
+ if ( elem === pickerRoot ) { continue; }
1106
+ const srcs = resourceURLsFromElement(elem);
1107
+ if (
1108
+ (srcs.length !== 0 && srcs.includes(url) === false) ||
1109
+ (srcs.length === 0 && url !== 'about:blank')
1110
+ ) {
1111
+ continue;
1112
+ }
1113
+ filtersFrom(elem);
1114
+ if (
1115
+ netFilterCandidates.length !== 0 ||
1116
+ cosmeticFilterCandidates.length !== 0
1117
+ ) {
1118
+ if ( pickerBootArgs.mouse !== true ) {
1119
+ elem.scrollIntoView({
1120
+ behavior: 'smooth',
1121
+ block: 'center',
1122
+ inline: 'center'
1123
+ });
1124
+ }
1125
+ showDialog({ broad: true });
1126
+ }
1127
+ return;
1128
+ }
1129
+
1130
+ // A target was specified, but it wasn't found: abort.
1131
+ quitPicker();
1132
+ };
1133
+
1134
+ /******************************************************************************/
1135
+
1136
+ // Let's have the element picker code flushed from memory when no longer
1137
+ // in use: to ensure this, release all local references.
1138
+
1139
+ const quitPicker = function() {
1140
+ self.removeEventListener('scroll', onViewportChanged, { passive: true });
1141
+ self.removeEventListener('resize', onViewportChanged, { passive: true });
1142
+ self.removeEventListener('keydown', onKeyPressed, true);
1143
+ vAPI.shutdown.remove(quitPicker);
1144
+ vAPI.MessagingConnection.disconnectFrom(epickerConnectionId);
1145
+ vAPI.MessagingConnection.removeListener(onConnectionMessage);
1146
+ vAPI.userStylesheet.remove(pickerCSS);
1147
+ vAPI.userStylesheet.apply();
1148
+
1149
+ if ( pickerRoot === null ) { return; }
1150
+
1151
+ pickerRoot.remove();
1152
+ pickerRoot = null;
1153
+
1154
+ self.focus();
1155
+ };
1156
+
1157
+ /******************************************************************************/
1158
+
1159
+ const onDialogMessage = function(msg) {
1160
+ switch ( msg.what ) {
1161
+ case 'start':
1162
+ startPicker();
1163
+ if ( targetElements.length === 0 ) {
1164
+ highlightElements([], true);
1165
+ }
1166
+ break;
1167
+ case 'optimizeCandidates':
1168
+ onOptimizeCandidates(msg);
1169
+ break;
1170
+ case 'dialogCreate':
1171
+ filterToDOMInterface.queryAll(msg);
1172
+ filterToDOMInterface.preview(true, true);
1173
+ quitPicker();
1174
+ break;
1175
+ case 'dialogSetFilter': {
1176
+ const resultset = filterToDOMInterface.queryAll(msg) || [];
1177
+ highlightElements(resultset.map(a => a.elem), true);
1178
+ if ( msg.filter === '!' ) { break; }
1179
+ vAPI.MessagingConnection.sendTo(epickerConnectionId, {
1180
+ what: 'resultsetDetails',
1181
+ count: resultset.length,
1182
+ opt: resultset.length !== 0 ? resultset[0].opt : undefined,
1183
+ });
1184
+ break;
1185
+ }
1186
+ case 'quitPicker':
1187
+ filterToDOMInterface.preview(false);
1188
+ quitPicker();
1189
+ break;
1190
+ case 'highlightElementAtPoint':
1191
+ highlightElementAtPoint(msg.mx, msg.my);
1192
+ break;
1193
+ case 'unhighlight':
1194
+ highlightElements([]);
1195
+ break;
1196
+ case 'filterElementAtPoint':
1197
+ filterElementAtPoint(msg.mx, msg.my, msg.broad);
1198
+ break;
1199
+ case 'zapElementAtPoint':
1200
+ zapElementAtPoint(msg.mx, msg.my, msg.options);
1201
+ if ( msg.options.highlight !== true && msg.options.stay !== true ) {
1202
+ quitPicker();
1203
+ }
1204
+ break;
1205
+ case 'togglePreview':
1206
+ filterToDOMInterface.preview(msg.state);
1207
+ if ( msg.state === false ) {
1208
+ highlightElements(targetElements, true);
1209
+ }
1210
+ break;
1211
+ default:
1212
+ break;
1213
+ }
1214
+ };
1215
+
1216
+ /******************************************************************************/
1217
+
1218
+ const onConnectionMessage = function(msg) {
1219
+ if ( msg.from !== `epickerDialog-${epickerId}` ) { return; }
1220
+ switch ( msg.what ) {
1221
+ case 'connectionRequested':
1222
+ epickerConnectionId = msg.id;
1223
+ return true;
1224
+ case 'connectionBroken':
1225
+ quitPicker();
1226
+ break;
1227
+ case 'connectionMessage':
1228
+ onDialogMessage(msg.payload);
1229
+ break;
1230
+ }
1231
+ };
1232
+
1233
+ /******************************************************************************/
1234
+
1235
+ // epicker-ui.html will be injected in the page through an iframe, and
1236
+ // is a sandboxed so as to prevent the page from interfering with its
1237
+ // content and behavior.
1238
+ //
1239
+ // The purpose of epicker.js is to:
1240
+ // - Install the element picker UI, and wait for the component to establish
1241
+ // a direct communication channel.
1242
+ // - Lookup candidate filters from elements at a specific position.
1243
+ // - Highlight element(s) at a specific position or according to whether
1244
+ // they match candidate filters;
1245
+ // - Preview the result of applying a candidate filter;
1246
+ //
1247
+ // When the element picker is installed on a page, the only change the page
1248
+ // sees is an iframe with a random attribute. The page can't see the content
1249
+ // of the iframe, and cannot interfere with its style properties. However the
1250
+ // page can remove the iframe.
1251
+
1252
+ // We need extra messaging capabilities + fetch/process picker arguments.
1253
+ {
1254
+ const results = await Promise.all([
1255
+ vAPI.messaging.extend(),
1256
+ vAPI.messaging.send('elementPicker', { what: 'elementPickerArguments' }),
1257
+ ]);
1258
+ if ( results[0] !== true ) { return; }
1259
+ pickerBootArgs = results[1];
1260
+ if ( typeof pickerBootArgs !== 'object' || pickerBootArgs === null ) {
1261
+ return;
1262
+ }
1263
+ // Restore net filter union data if origin is the same.
1264
+ const eprom = pickerBootArgs.eprom || null;
1265
+ if ( eprom !== null && eprom.lastNetFilterSession === lastNetFilterSession ) {
1266
+ lastNetFilterHostname = eprom.lastNetFilterHostname || '';
1267
+ lastNetFilterUnion = eprom.lastNetFilterUnion || '';
1268
+ }
1269
+ }
1270
+
1271
+ // The DOM filterer will not be present when cosmetic filtering is disabled.
1272
+ const noCosmeticFiltering =
1273
+ vAPI.domFilterer instanceof Object === false ||
1274
+ vAPI.noSpecificCosmeticFiltering === true;
1275
+
1276
+ // https://github.com/gorhill/uBlock/issues/1529
1277
+ // In addition to inline styles, harden the element picker styles by using
1278
+ // dedicated CSS rules.
1279
+ const pickerCSSStyle = [
1280
+ 'background: transparent',
1281
+ 'border: 0',
1282
+ 'border-radius: 0',
1283
+ 'box-shadow: none',
1284
+ 'color-scheme: light dark',
1285
+ 'display: block',
1286
+ 'filter: none',
1287
+ 'height: 100vh',
1288
+ 'left: 0',
1289
+ 'margin: 0',
1290
+ 'max-height: none',
1291
+ 'max-width: none',
1292
+ 'min-height: unset',
1293
+ 'min-width: unset',
1294
+ 'opacity: 1',
1295
+ 'outline: 0',
1296
+ 'padding: 0',
1297
+ 'pointer-events: auto',
1298
+ 'position: fixed',
1299
+ 'top: 0',
1300
+ 'transform: none',
1301
+ 'visibility: hidden',
1302
+ 'width: 100%',
1303
+ 'z-index: 2147483647',
1304
+ ''
1305
+ ];
1306
+
1307
+
1308
+ const pickerCSS = `
1309
+ :root > [${vAPI.sessionId}] {
1310
+ ${pickerCSSStyle.join(' !important;')}
1311
+ }
1312
+ :root > [${vAPI.sessionId}-loaded] {
1313
+ visibility: visible !important;
1314
+ }
1315
+ :root [${vAPI.sessionId}-clickblind] {
1316
+ pointer-events: none !important;
1317
+ }
1318
+ `;
1319
+
1320
+ vAPI.userStylesheet.add(pickerCSS);
1321
+ vAPI.userStylesheet.apply();
1322
+
1323
+ pickerRoot = document.createElement('iframe');
1324
+ pickerRoot.setAttribute(vAPI.sessionId, '');
1325
+ document.documentElement.append(pickerRoot);
1326
+
1327
+ vAPI.shutdown.add(quitPicker);
1328
+
1329
+ vAPI.MessagingConnection.addListener(onConnectionMessage);
1330
+
1331
+ {
1332
+ const url = new URL(pickerBootArgs.pickerURL);
1333
+ url.searchParams.set('epid', epickerId);
1334
+ if ( pickerBootArgs.zap ) {
1335
+ url.searchParams.set('zap', '1');
1336
+ }
1337
+ pickerRoot.addEventListener("load", function() {
1338
+ pickerRoot.setAttribute(`${vAPI.sessionId}-loaded`, "");
1339
+ });
1340
+ pickerRoot.src = url.href;
1341
+ }
1342
+
1343
+ /******************************************************************************/
1344
+
1345
+ })();
1346
+
1347
+
1348
+
1349
+
1350
+
1351
+
1352
+
1353
+
1354
+ /*******************************************************************************
1355
+
1356
+ DO NOT:
1357
+ - Remove the following code
1358
+ - Add code beyond the following code
1359
+ Reason:
1360
+ - https://github.com/gorhill/uBlock/pull/3721
1361
+ - uBO never uses the return value from injected content scripts
1362
+
1363
+ **/
1364
+
1365
+ void 0;