@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.
- package/CHANGELOG.md +674 -0
- package/LICENSE +6 -0
- package/README.md +132 -0
- package/assets/logo.png +0 -0
- package/bin/browserless.js +227 -0
- package/browser.json +7 -0
- package/build/browserless.d.ts +33 -0
- package/build/browserless.js +146 -0
- package/build/browsers/cdp-chromium.d.ts +41 -0
- package/build/browsers/cdp-chromium.js +287 -0
- package/build/browsers/index.d.ts +26 -0
- package/build/browsers/index.js +183 -0
- package/build/browsers/playwright-chromium.d.ts +34 -0
- package/build/browsers/playwright-chromium.js +106 -0
- package/build/browsers/playwright-firefox.d.ts +34 -0
- package/build/browsers/playwright-firefox.js +101 -0
- package/build/browsers/playwright-webkit.d.ts +34 -0
- package/build/browsers/playwright-webkit.js +101 -0
- package/build/config.d.ts +138 -0
- package/build/config.js +349 -0
- package/build/constants.d.ts +4 -0
- package/build/constants.js +4 -0
- package/build/data/classes.json +1 -0
- package/build/data/selectors.json +1 -0
- package/build/exports.d.ts +20 -0
- package/build/exports.js +22 -0
- package/build/file-system.d.ts +24 -0
- package/build/file-system.js +46 -0
- package/build/hooks.d.ts +5 -0
- package/build/hooks.js +20 -0
- package/build/http.d.ts +175 -0
- package/build/http.js +104 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +39 -0
- package/build/limiter.d.ts +24 -0
- package/build/limiter.js +147 -0
- package/build/limiter.spec.d.ts +1 -0
- package/build/limiter.spec.js +241 -0
- package/build/metrics.d.ts +24 -0
- package/build/metrics.js +86 -0
- package/build/metrics.spec.d.ts +1 -0
- package/build/metrics.spec.js +35 -0
- package/build/mime-types.d.ts +1 -0
- package/build/mime-types.js +328 -0
- package/build/monitoring.d.ts +13 -0
- package/build/monitoring.js +38 -0
- package/build/routes/chromium/http/content-post.body.json +514 -0
- package/build/routes/chromium/http/content-post.d.ts +34 -0
- package/build/routes/chromium/http/content-post.js +109 -0
- package/build/routes/chromium/http/content-post.query.json +183 -0
- package/build/routes/chromium/http/content-post.response.json +5 -0
- package/build/routes/chromium/http/download-post.body.json +32 -0
- package/build/routes/chromium/http/download-post.d.ts +16 -0
- package/build/routes/chromium/http/download-post.js +92 -0
- package/build/routes/chromium/http/download-post.query.json +120 -0
- package/build/routes/chromium/http/download-post.response.json +4 -0
- package/build/routes/chromium/http/function-post.body.json +32 -0
- package/build/routes/chromium/http/function-post.d.ts +18 -0
- package/build/routes/chromium/http/function-post.js +53 -0
- package/build/routes/chromium/http/function-post.query.json +120 -0
- package/build/routes/chromium/http/function-post.response.json +4 -0
- package/build/routes/chromium/http/pdf-post.body.json +654 -0
- package/build/routes/chromium/http/pdf-post.d.ts +35 -0
- package/build/routes/chromium/http/pdf-post.js +107 -0
- package/build/routes/chromium/http/pdf-post.query.json +120 -0
- package/build/routes/chromium/http/pdf-post.response.json +5 -0
- package/build/routes/chromium/http/performance.body.json +26 -0
- package/build/routes/chromium/http/performance.d.ts +17 -0
- package/build/routes/chromium/http/performance.js +30 -0
- package/build/routes/chromium/http/performance.query.json +120 -0
- package/build/routes/chromium/http/performance.response.json +7 -0
- package/build/routes/chromium/http/scrape-post.body.json +561 -0
- package/build/routes/chromium/http/scrape-post.d.ts +106 -0
- package/build/routes/chromium/http/scrape-post.js +205 -0
- package/build/routes/chromium/http/scrape-post.query.json +183 -0
- package/build/routes/chromium/http/scrape-post.response.json +325 -0
- package/build/routes/chromium/http/screenshot-post.body.json +604 -0
- package/build/routes/chromium/http/screenshot-post.d.ts +37 -0
- package/build/routes/chromium/http/screenshot-post.js +124 -0
- package/build/routes/chromium/http/screenshot-post.query.json +120 -0
- package/build/routes/chromium/http/screenshot-post.response.json +5 -0
- package/build/routes/chromium/tests/content.spec.d.ts +1 -0
- package/build/routes/chromium/tests/content.spec.js +285 -0
- package/build/routes/chromium/tests/download.spec.d.ts +1 -0
- package/build/routes/chromium/tests/download.spec.js +67 -0
- package/build/routes/chromium/tests/function.spec.d.ts +1 -0
- package/build/routes/chromium/tests/function.spec.js +245 -0
- package/build/routes/chromium/tests/pdf.spec.d.ts +1 -0
- package/build/routes/chromium/tests/pdf.spec.js +333 -0
- package/build/routes/chromium/tests/performance.spec.d.ts +1 -0
- package/build/routes/chromium/tests/performance.spec.js +124 -0
- package/build/routes/chromium/tests/scrape.spec.d.ts +1 -0
- package/build/routes/chromium/tests/scrape.spec.js +354 -0
- package/build/routes/chromium/tests/screenshot.spec.d.ts +1 -0
- package/build/routes/chromium/tests/screenshot.spec.js +339 -0
- package/build/routes/chromium/tests/websocket.spec.d.ts +1 -0
- package/build/routes/chromium/tests/websocket.spec.js +309 -0
- package/build/routes/chromium/utils/function/client.d.ts +26 -0
- package/build/routes/chromium/utils/function/client.js +66 -0
- package/build/routes/chromium/utils/function/handler.d.ts +18 -0
- package/build/routes/chromium/utils/function/handler.js +95 -0
- package/build/routes/chromium/utils/performance/child.d.ts +1 -0
- package/build/routes/chromium/utils/performance/child.js +29 -0
- package/build/routes/chromium/utils/performance/main.d.ts +3 -0
- package/build/routes/chromium/utils/performance/main.js +65 -0
- package/build/routes/chromium/utils/performance/types.d.ts +21 -0
- package/build/routes/chromium/utils/performance/types.js +1 -0
- package/build/routes/chromium/ws/browser.d.ts +6 -0
- package/build/routes/chromium/ws/browser.js +11 -0
- package/build/routes/chromium/ws/browser.query.json +120 -0
- package/build/routes/chromium/ws/cdp-chromium.d.ts +6 -0
- package/build/routes/chromium/ws/cdp-chromium.js +11 -0
- package/build/routes/chromium/ws/cdp-chromium.query.json +120 -0
- package/build/routes/chromium/ws/page.d.ts +6 -0
- package/build/routes/chromium/ws/page.js +11 -0
- package/build/routes/chromium/ws/page.query.json +120 -0
- package/build/routes/chromium/ws/playwright-chromium.d.ts +6 -0
- package/build/routes/chromium/ws/playwright-chromium.js +19 -0
- package/build/routes/chromium/ws/playwright-chromium.query.json +100 -0
- package/build/routes/firefox/tests/websocket.spec.d.ts +1 -0
- package/build/routes/firefox/tests/websocket.spec.js +104 -0
- package/build/routes/firefox/ws/playwright-firefox.d.ts +6 -0
- package/build/routes/firefox/ws/playwright-firefox.js +19 -0
- package/build/routes/firefox/ws/playwright-firefox.query.json +100 -0
- package/build/routes/management/http/config-get.d.ts +25 -0
- package/build/routes/management/http/config-get.js +43 -0
- package/build/routes/management/http/config-get.response.json +107 -0
- package/build/routes/management/http/metrics-get.d.ts +4 -0
- package/build/routes/management/http/metrics-get.js +24 -0
- package/build/routes/management/http/metrics-get.response.json +94 -0
- package/build/routes/management/http/metrics-total-get.d.ts +4 -0
- package/build/routes/management/http/metrics-total-get.js +60 -0
- package/build/routes/management/http/metrics-total-get.response.json +72 -0
- package/build/routes/management/http/sessions-get.d.ts +4 -0
- package/build/routes/management/http/sessions-get.js +21 -0
- package/build/routes/management/http/sessions-get.response.json +221 -0
- package/build/routes/management/http/static-get.d.ts +3 -0
- package/build/routes/management/http/static-get.js +67 -0
- package/build/routes/management/tests/management.spec.d.ts +1 -0
- package/build/routes/management/tests/management.spec.js +41 -0
- package/build/routes/webkit/tests/websocket.spec.d.ts +1 -0
- package/build/routes/webkit/tests/websocket.spec.js +104 -0
- package/build/routes/webkit/ws/playwright-webkit.d.ts +6 -0
- package/build/routes/webkit/ws/playwright-webkit.js +19 -0
- package/build/routes/webkit/ws/playwright-webkit.query.json +100 -0
- package/build/server.d.ts +38 -0
- package/build/server.js +365 -0
- package/build/shim.d.ts +9 -0
- package/build/shim.js +54 -0
- package/build/shim.spec.d.ts +1 -0
- package/build/shim.spec.js +114 -0
- package/build/types.d.ts +360 -0
- package/build/types.js +6 -0
- package/build/utils.d.ts +111 -0
- package/build/utils.js +570 -0
- package/build/webhooks.d.ts +11 -0
- package/build/webhooks.js +43 -0
- package/docker/base/.dockerignore +16 -0
- package/docker/base/Dockerfile +70 -0
- package/docker/chrome/.dockerignore +16 -0
- package/docker/chrome/Dockerfile +40 -0
- package/docker/firefox/.dockerignore +16 -0
- package/docker/firefox/Dockerfile +39 -0
- package/docker/multi/.dockerignore +16 -0
- package/docker/multi/Dockerfile +37 -0
- package/docker/sdk/.dockerignore +16 -0
- package/docker/sdk/Dockerfile +34 -0
- package/docker/webkit/.dockerignore +16 -0
- package/docker/webkit/Dockerfile +40 -0
- package/extensions/screencast/background.js +143 -0
- package/extensions/screencast/content_script.js +18 -0
- package/extensions/screencast/manifest.json +19 -0
- package/extensions/ublock/1p-filters.html +69 -0
- package/extensions/ublock/3p-filters.html +119 -0
- package/extensions/ublock/LICENSE.txt +674 -0
- package/extensions/ublock/_locales/ar/messages.json +1290 -0
- package/extensions/ublock/_locales/az/messages.json +1290 -0
- package/extensions/ublock/_locales/be/messages.json +1290 -0
- package/extensions/ublock/_locales/bg/messages.json +1290 -0
- package/extensions/ublock/_locales/bn/messages.json +1290 -0
- package/extensions/ublock/_locales/br_FR/messages.json +1290 -0
- package/extensions/ublock/_locales/bs/messages.json +1290 -0
- package/extensions/ublock/_locales/ca/messages.json +1290 -0
- package/extensions/ublock/_locales/cs/messages.json +1290 -0
- package/extensions/ublock/_locales/cv/messages.json +1290 -0
- package/extensions/ublock/_locales/da/messages.json +1290 -0
- package/extensions/ublock/_locales/de/messages.json +1290 -0
- package/extensions/ublock/_locales/el/messages.json +1290 -0
- package/extensions/ublock/_locales/en/messages.json +1292 -0
- package/extensions/ublock/_locales/en_GB/messages.json +1290 -0
- package/extensions/ublock/_locales/eo/messages.json +1290 -0
- package/extensions/ublock/_locales/es/messages.json +1290 -0
- package/extensions/ublock/_locales/et/messages.json +1290 -0
- package/extensions/ublock/_locales/eu/messages.json +1290 -0
- package/extensions/ublock/_locales/fa/messages.json +1290 -0
- package/extensions/ublock/_locales/fi/messages.json +1290 -0
- package/extensions/ublock/_locales/fil/messages.json +1290 -0
- package/extensions/ublock/_locales/fr/messages.json +1290 -0
- package/extensions/ublock/_locales/fy/messages.json +1290 -0
- package/extensions/ublock/_locales/gl/messages.json +1290 -0
- package/extensions/ublock/_locales/gu/messages.json +1290 -0
- package/extensions/ublock/_locales/he/messages.json +1290 -0
- package/extensions/ublock/_locales/hi/messages.json +1290 -0
- package/extensions/ublock/_locales/hr/messages.json +1290 -0
- package/extensions/ublock/_locales/hu/messages.json +1290 -0
- package/extensions/ublock/_locales/hy/messages.json +1290 -0
- package/extensions/ublock/_locales/id/messages.json +1290 -0
- package/extensions/ublock/_locales/it/messages.json +1290 -0
- package/extensions/ublock/_locales/ja/messages.json +1290 -0
- package/extensions/ublock/_locales/ka/messages.json +1290 -0
- package/extensions/ublock/_locales/kk/messages.json +1290 -0
- package/extensions/ublock/_locales/kn/messages.json +1290 -0
- package/extensions/ublock/_locales/ko/messages.json +1290 -0
- package/extensions/ublock/_locales/ku/messages.json +1290 -0
- package/extensions/ublock/_locales/lt/messages.json +1290 -0
- package/extensions/ublock/_locales/lv/messages.json +1290 -0
- package/extensions/ublock/_locales/mk/messages.json +1290 -0
- package/extensions/ublock/_locales/ml/messages.json +1290 -0
- package/extensions/ublock/_locales/mr/messages.json +1290 -0
- package/extensions/ublock/_locales/ms/messages.json +1290 -0
- package/extensions/ublock/_locales/nb/messages.json +1290 -0
- package/extensions/ublock/_locales/nl/messages.json +1290 -0
- package/extensions/ublock/_locales/no/messages.json +1290 -0
- package/extensions/ublock/_locales/oc/messages.json +1290 -0
- package/extensions/ublock/_locales/pa/messages.json +1290 -0
- package/extensions/ublock/_locales/pl/messages.json +1290 -0
- package/extensions/ublock/_locales/pt_BR/messages.json +1290 -0
- package/extensions/ublock/_locales/pt_PT/messages.json +1290 -0
- package/extensions/ublock/_locales/ro/messages.json +1290 -0
- package/extensions/ublock/_locales/ru/messages.json +1290 -0
- package/extensions/ublock/_locales/si/messages.json +1290 -0
- package/extensions/ublock/_locales/sk/messages.json +1290 -0
- package/extensions/ublock/_locales/sl/messages.json +1290 -0
- package/extensions/ublock/_locales/so/messages.json +1290 -0
- package/extensions/ublock/_locales/sq/messages.json +1290 -0
- package/extensions/ublock/_locales/sr/messages.json +1290 -0
- package/extensions/ublock/_locales/sv/messages.json +1290 -0
- package/extensions/ublock/_locales/sw/messages.json +1290 -0
- package/extensions/ublock/_locales/ta/messages.json +1290 -0
- package/extensions/ublock/_locales/te/messages.json +1290 -0
- package/extensions/ublock/_locales/th/messages.json +1290 -0
- package/extensions/ublock/_locales/tr/messages.json +1290 -0
- package/extensions/ublock/_locales/uk/messages.json +1290 -0
- package/extensions/ublock/_locales/ur/messages.json +1290 -0
- package/extensions/ublock/_locales/vi/messages.json +1290 -0
- package/extensions/ublock/_locales/zh_CN/messages.json +1290 -0
- package/extensions/ublock/_locales/zh_TW/messages.json +1290 -0
- package/extensions/ublock/about.html +63 -0
- package/extensions/ublock/advanced-settings.html +42 -0
- package/extensions/ublock/asset-viewer.html +50 -0
- package/extensions/ublock/assets/assets.json +903 -0
- package/extensions/ublock/assets/resources/scriptlets.js +4255 -0
- package/extensions/ublock/assets/thirdparties/easylist/easylist.txt +65576 -0
- package/extensions/ublock/assets/thirdparties/easylist/easyprivacy.txt +33219 -0
- package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/README.md +29 -0
- package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/serverlist +3732 -0
- package/extensions/ublock/assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat +15431 -0
- package/extensions/ublock/assets/thirdparties/urlhaus-filter/LICENSE.md +42 -0
- package/extensions/ublock/assets/thirdparties/urlhaus-filter/urlhaus-filter-online.txt +1970 -0
- package/extensions/ublock/assets/ublock/badlists.txt +77 -0
- package/extensions/ublock/assets/ublock/badware.min.txt +3033 -0
- package/extensions/ublock/assets/ublock/filters.min.txt +23419 -0
- package/extensions/ublock/assets/ublock/privacy.min.txt +575 -0
- package/extensions/ublock/assets/ublock/quick-fixes.min.txt +99 -0
- package/extensions/ublock/assets/ublock/unbreak.min.txt +2448 -0
- package/extensions/ublock/background.html +12 -0
- package/extensions/ublock/cloud-ui.html +23 -0
- package/extensions/ublock/code-viewer.html +53 -0
- package/extensions/ublock/css/1p-filters.css +26 -0
- package/extensions/ublock/css/3p-filters.css +250 -0
- package/extensions/ublock/css/about.css +3 -0
- package/extensions/ublock/css/advanced-settings.css +26 -0
- package/extensions/ublock/css/asset-viewer.css +79 -0
- package/extensions/ublock/css/click2load.css +53 -0
- package/extensions/ublock/css/cloud-ui.css +104 -0
- package/extensions/ublock/css/code-viewer.css +67 -0
- package/extensions/ublock/css/codemirror.css +326 -0
- package/extensions/ublock/css/common.css +347 -0
- package/extensions/ublock/css/dashboard-common.css +55 -0
- package/extensions/ublock/css/dashboard.css +115 -0
- package/extensions/ublock/css/devtools.css +22 -0
- package/extensions/ublock/css/document-blocked.css +146 -0
- package/extensions/ublock/css/dyna-rules.css +79 -0
- package/extensions/ublock/css/epicker-ui.css +270 -0
- package/extensions/ublock/css/fa-icons.css +149 -0
- package/extensions/ublock/css/fonts/Inter/Inter-Regular.woff2 +0 -0
- package/extensions/ublock/css/fonts/Inter/Inter-SemiBold.woff2 +0 -0
- package/extensions/ublock/css/fonts/Inter/LICENSE.txt +93 -0
- package/extensions/ublock/css/fonts/Metropolis/Metropolis-Regular.woff2 +0 -0
- package/extensions/ublock/css/fonts/Metropolis/Metropolis-SemiBold.woff2 +0 -0
- package/extensions/ublock/css/fonts/Metropolis/README.md +25 -0
- package/extensions/ublock/css/fonts/Metropolis/UNLICENSE +24 -0
- package/extensions/ublock/css/logger-ui-inspector.css +116 -0
- package/extensions/ublock/css/logger-ui.css +978 -0
- package/extensions/ublock/css/popup-fenix.css +778 -0
- package/extensions/ublock/css/settings.css +74 -0
- package/extensions/ublock/css/support.css +110 -0
- package/extensions/ublock/css/themes/default.css +526 -0
- package/extensions/ublock/css/whitelist.css +22 -0
- package/extensions/ublock/dashboard.html +47 -0
- package/extensions/ublock/devtools.html +58 -0
- package/extensions/ublock/document-blocked.html +64 -0
- package/extensions/ublock/dyna-rules.html +67 -0
- package/extensions/ublock/img/cloud.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/README +9 -0
- package/extensions/ublock/img/flags-of-the-world/ad.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ae.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/af.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ag.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ai.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/al.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/am.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ao.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/aq.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ar.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/as.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/at.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/au.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/aw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ax.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/az.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ba.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bb.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bd.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/be.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bh.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bi.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bj.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bo.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bq.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/br.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bs.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bv.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/by.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/bz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ca.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cd.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ch.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ci.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ck.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/co.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cv.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cx.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cy.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/cz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/de.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/dj.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/dk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/dm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/do.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/dz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ec.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ee.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/eg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/eh.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/er.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/es.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/et.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/fi.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/fj.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/fk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/fm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/fo.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/fr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ga.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gb-eng.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gb-nir.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gb-sct.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gb-wls.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gb.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gd.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ge.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gh.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gi.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gp.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gq.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gs.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/gy.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/hk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/hm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/hn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/hr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ht.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/hu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/id.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ie.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/il.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/im.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/in.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/io.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/iq.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ir.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/is.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/it.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/je.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/jm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/jo.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/jp.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ke.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kh.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ki.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/km.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kp.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ky.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/kz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/la.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lb.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/li.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ls.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/lv.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ly.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ma.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/md.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/me.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mh.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ml.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mo.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mp.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mq.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ms.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mv.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mx.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/my.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/mz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/na.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/nc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ne.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/nf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ng.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ni.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/nl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/no.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/np.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/nr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/nu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/nz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/om.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pa.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pe.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ph.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ps.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/pw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/py.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/qa.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/re.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ro.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/rs.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ru.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/rw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sa.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sb.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sd.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/se.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sh.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/si.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sj.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/so.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ss.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/st.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sv.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sx.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sy.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/sz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/td.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/th.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tj.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tl.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/to.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tr.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tv.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tw.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/tz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ua.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ug.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/um.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/us.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/uy.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/uz.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/va.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/vc.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ve.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/vg.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/vi.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/vn.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/vu.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/wf.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ws.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/xk.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/ye.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/yt.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/za.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/zm.png +0 -0
- package/extensions/ublock/img/flags-of-the-world/zw.png +0 -0
- package/extensions/ublock/img/fontawesome/LICENSE.txt +25 -0
- package/extensions/ublock/img/fontawesome/fontawesome-defs.svg +79 -0
- package/extensions/ublock/img/help16.png +0 -0
- package/extensions/ublock/img/icon_128.png +0 -0
- package/extensions/ublock/img/icon_16-loading.png +0 -0
- package/extensions/ublock/img/icon_16-off.png +0 -0
- package/extensions/ublock/img/icon_16.png +0 -0
- package/extensions/ublock/img/icon_32-loading.png +0 -0
- package/extensions/ublock/img/icon_32-off.png +0 -0
- package/extensions/ublock/img/icon_32.png +0 -0
- package/extensions/ublock/img/icon_64-loading.png +0 -0
- package/extensions/ublock/img/icon_64-off.png +0 -0
- package/extensions/ublock/img/icon_64.png +0 -0
- package/extensions/ublock/img/material-design.svg +16 -0
- package/extensions/ublock/img/photon.svg +16 -0
- package/extensions/ublock/img/ublock-defs.svg +27 -0
- package/extensions/ublock/img/ublock.svg +44 -0
- package/extensions/ublock/is-webrtc-supported.html +9 -0
- package/extensions/ublock/js/1p-filters.js +336 -0
- package/extensions/ublock/js/3p-filters.js +867 -0
- package/extensions/ublock/js/about.js +34 -0
- package/extensions/ublock/js/advanced-settings.js +194 -0
- package/extensions/ublock/js/asset-viewer.js +112 -0
- package/extensions/ublock/js/assets.js +1448 -0
- package/extensions/ublock/js/background.js +404 -0
- package/extensions/ublock/js/base64-custom.js +246 -0
- package/extensions/ublock/js/benchmarks.js +421 -0
- package/extensions/ublock/js/biditrie.js +947 -0
- package/extensions/ublock/js/cachestorage.js +510 -0
- package/extensions/ublock/js/click2load.js +60 -0
- package/extensions/ublock/js/cloud-ui.js +238 -0
- package/extensions/ublock/js/code-viewer.js +311 -0
- package/extensions/ublock/js/codemirror/search-thread.js +199 -0
- package/extensions/ublock/js/codemirror/search.js +504 -0
- package/extensions/ublock/js/codemirror/ubo-dynamic-filtering.js +239 -0
- package/extensions/ublock/js/codemirror/ubo-static-filtering.js +1126 -0
- package/extensions/ublock/js/commands.js +181 -0
- package/extensions/ublock/js/console.js +59 -0
- package/extensions/ublock/js/contentscript-extra.js +662 -0
- package/extensions/ublock/js/contentscript.js +1366 -0
- package/extensions/ublock/js/contextmenu.js +270 -0
- package/extensions/ublock/js/cosmetic-filtering.js +983 -0
- package/extensions/ublock/js/dashboard-common.js +215 -0
- package/extensions/ublock/js/dashboard.js +166 -0
- package/extensions/ublock/js/devtools.js +184 -0
- package/extensions/ublock/js/diff-updater.js +288 -0
- package/extensions/ublock/js/document-blocked.js +230 -0
- package/extensions/ublock/js/dom.js +213 -0
- package/extensions/ublock/js/dyna-rules.js +678 -0
- package/extensions/ublock/js/dynamic-net-filtering.js +488 -0
- package/extensions/ublock/js/epicker-ui.js +924 -0
- package/extensions/ublock/js/fa-icons.js +129 -0
- package/extensions/ublock/js/filtering-context.js +461 -0
- package/extensions/ublock/js/filtering-engines.js +50 -0
- package/extensions/ublock/js/hnswitches.js +289 -0
- package/extensions/ublock/js/hntrie.js +780 -0
- package/extensions/ublock/js/html-filtering.js +465 -0
- package/extensions/ublock/js/httpheader-filtering.js +213 -0
- package/extensions/ublock/js/i18n.js +346 -0
- package/extensions/ublock/js/is-webrtc-supported.js +52 -0
- package/extensions/ublock/js/logger-ui-inspector.js +652 -0
- package/extensions/ublock/js/logger-ui.js +3028 -0
- package/extensions/ublock/js/logger.js +84 -0
- package/extensions/ublock/js/lz4.js +190 -0
- package/extensions/ublock/js/messaging.js +2095 -0
- package/extensions/ublock/js/pagestore.js +1140 -0
- package/extensions/ublock/js/popup-fenix.js +1529 -0
- package/extensions/ublock/js/redirect-engine.js +494 -0
- package/extensions/ublock/js/redirect-resources.js +193 -0
- package/extensions/ublock/js/reverselookup-worker.js +287 -0
- package/extensions/ublock/js/reverselookup.js +223 -0
- package/extensions/ublock/js/scriptlet-filtering.js +556 -0
- package/extensions/ublock/js/scriptlets/cosmetic-logger.js +376 -0
- package/extensions/ublock/js/scriptlets/cosmetic-off.js +48 -0
- package/extensions/ublock/js/scriptlets/cosmetic-on.js +48 -0
- package/extensions/ublock/js/scriptlets/cosmetic-report.js +142 -0
- package/extensions/ublock/js/scriptlets/dom-inspector.js +906 -0
- package/extensions/ublock/js/scriptlets/dom-survey-elements.js +72 -0
- package/extensions/ublock/js/scriptlets/dom-survey-scripts.js +126 -0
- package/extensions/ublock/js/scriptlets/epicker.js +1365 -0
- package/extensions/ublock/js/scriptlets/load-3p-css.js +67 -0
- package/extensions/ublock/js/scriptlets/load-large-media-all.js +62 -0
- package/extensions/ublock/js/scriptlets/load-large-media-interactive.js +299 -0
- package/extensions/ublock/js/scriptlets/noscript-spoof.js +89 -0
- package/extensions/ublock/js/scriptlets/should-inject-contentscript.js +40 -0
- package/extensions/ublock/js/scriptlets/subscriber.js +113 -0
- package/extensions/ublock/js/scriptlets/updater.js +101 -0
- package/extensions/ublock/js/settings.js +317 -0
- package/extensions/ublock/js/start.js +509 -0
- package/extensions/ublock/js/static-dnr-filtering.js +497 -0
- package/extensions/ublock/js/static-ext-filtering-db.js +171 -0
- package/extensions/ublock/js/static-ext-filtering.js +184 -0
- package/extensions/ublock/js/static-filtering-io.js +144 -0
- package/extensions/ublock/js/static-filtering-parser.js +4459 -0
- package/extensions/ublock/js/static-net-filtering.js +5631 -0
- package/extensions/ublock/js/storage.js +1683 -0
- package/extensions/ublock/js/support.js +335 -0
- package/extensions/ublock/js/tab.js +1178 -0
- package/extensions/ublock/js/tasks.js +42 -0
- package/extensions/ublock/js/text-encode.js +275 -0
- package/extensions/ublock/js/text-utils.js +107 -0
- package/extensions/ublock/js/theme.js +151 -0
- package/extensions/ublock/js/traffic.js +1260 -0
- package/extensions/ublock/js/ublock.js +696 -0
- package/extensions/ublock/js/uri-utils.js +175 -0
- package/extensions/ublock/js/url-net-filtering.js +336 -0
- package/extensions/ublock/js/utils.js +208 -0
- package/extensions/ublock/js/vapi-background-ext.js +254 -0
- package/extensions/ublock/js/vapi-background.js +1802 -0
- package/extensions/ublock/js/vapi-client-extra.js +312 -0
- package/extensions/ublock/js/vapi-client.js +280 -0
- package/extensions/ublock/js/vapi-common.js +308 -0
- package/extensions/ublock/js/vapi.js +89 -0
- package/extensions/ublock/js/wasm/README.md +24 -0
- package/extensions/ublock/js/wasm/biditrie.wasm +0 -0
- package/extensions/ublock/js/wasm/biditrie.wat +728 -0
- package/extensions/ublock/js/wasm/hntrie.wasm +0 -0
- package/extensions/ublock/js/wasm/hntrie.wat +724 -0
- package/extensions/ublock/js/webext.js +164 -0
- package/extensions/ublock/js/whitelist.js +258 -0
- package/extensions/ublock/lib/codemirror/LICENSE +21 -0
- package/extensions/ublock/lib/codemirror/README.md +47 -0
- package/extensions/ublock/lib/codemirror/addon/comment/comment.js +211 -0
- package/extensions/ublock/lib/codemirror/addon/display/panel.js +133 -0
- package/extensions/ublock/lib/codemirror/addon/edit/closebrackets.js +201 -0
- package/extensions/ublock/lib/codemirror/addon/edit/matchbrackets.js +160 -0
- package/extensions/ublock/lib/codemirror/addon/fold/foldcode.js +157 -0
- package/extensions/ublock/lib/codemirror/addon/fold/foldgutter.css +20 -0
- package/extensions/ublock/lib/codemirror/addon/fold/foldgutter.js +163 -0
- package/extensions/ublock/lib/codemirror/addon/hint/show-hint.css +36 -0
- package/extensions/ublock/lib/codemirror/addon/hint/show-hint.js +509 -0
- package/extensions/ublock/lib/codemirror/addon/merge/merge.css +119 -0
- package/extensions/ublock/lib/codemirror/addon/merge/merge.js +1006 -0
- package/extensions/ublock/lib/codemirror/addon/scroll/annotatescrollbar.js +128 -0
- package/extensions/ublock/lib/codemirror/addon/search/matchesonscrollbar.css +8 -0
- package/extensions/ublock/lib/codemirror/addon/search/searchcursor.js +296 -0
- package/extensions/ublock/lib/codemirror/addon/selection/active-line.js +72 -0
- package/extensions/ublock/lib/codemirror/lib/codemirror.css +350 -0
- package/extensions/ublock/lib/codemirror/lib/codemirror.js +9800 -0
- package/extensions/ublock/lib/codemirror/mode/css/css.js +864 -0
- package/extensions/ublock/lib/codemirror/mode/htmlmixed/htmlmixed.js +153 -0
- package/extensions/ublock/lib/codemirror/mode/javascript/javascript.js +942 -0
- package/extensions/ublock/lib/codemirror/mode/xml/xml.js +413 -0
- package/extensions/ublock/lib/codemirror/theme/night.css +27 -0
- package/extensions/ublock/lib/csstree/LICENSE +19 -0
- package/extensions/ublock/lib/csstree/css-tree.js +17 -0
- package/extensions/ublock/lib/diff/README.md +34 -0
- package/extensions/ublock/lib/diff/swatinem_diff.js +272 -0
- package/extensions/ublock/lib/hsluv/LICENSE +20 -0
- package/extensions/ublock/lib/hsluv/README +3 -0
- package/extensions/ublock/lib/hsluv/hsluv-0.1.0.min.js +8 -0
- package/extensions/ublock/lib/js-beautify/LICENSE +9 -0
- package/extensions/ublock/lib/js-beautify/README +5 -0
- package/extensions/ublock/lib/js-beautify/beautifier.min.js +2 -0
- package/extensions/ublock/lib/lz4/README.md +52 -0
- package/extensions/ublock/lib/lz4/lz4-block-codec-any.js +151 -0
- package/extensions/ublock/lib/lz4/lz4-block-codec-js.js +297 -0
- package/extensions/ublock/lib/lz4/lz4-block-codec-wasm.js +195 -0
- package/extensions/ublock/lib/lz4/lz4-block-codec.wasm +0 -0
- package/extensions/ublock/lib/lz4/lz4-block-codec.wat +745 -0
- package/extensions/ublock/lib/publicsuffixlist/publicsuffixlist.js +641 -0
- package/extensions/ublock/lib/publicsuffixlist/wasm/README.md +29 -0
- package/extensions/ublock/lib/publicsuffixlist/wasm/publicsuffixlist.wasm +0 -0
- package/extensions/ublock/lib/publicsuffixlist/wasm/publicsuffixlist.wat +322 -0
- package/extensions/ublock/lib/punycode.js +493 -0
- package/extensions/ublock/lib/regexanalyzer/CHANGES.md +15 -0
- package/extensions/ublock/lib/regexanalyzer/README.md +14 -0
- package/extensions/ublock/lib/regexanalyzer/regex.js +2276 -0
- package/extensions/ublock/logger-ui.html +232 -0
- package/extensions/ublock/managed_storage.json +73 -0
- package/extensions/ublock/manifest.json +115 -0
- package/extensions/ublock/no-dashboard.html +27 -0
- package/extensions/ublock/popup-fenix.html +114 -0
- package/extensions/ublock/settings.html +98 -0
- package/extensions/ublock/support.html +131 -0
- package/extensions/ublock/web_accessible_resources/1x1.gif +0 -0
- package/extensions/ublock/web_accessible_resources/2x2.png +0 -0
- package/extensions/ublock/web_accessible_resources/32x32.png +0 -0
- package/extensions/ublock/web_accessible_resources/3x2.png +0 -0
- package/extensions/ublock/web_accessible_resources/README.txt +11 -0
- package/extensions/ublock/web_accessible_resources/addthis_widget.js +39 -0
- package/extensions/ublock/web_accessible_resources/amazon_ads.js +70 -0
- package/extensions/ublock/web_accessible_resources/amazon_apstag.js +62 -0
- package/extensions/ublock/web_accessible_resources/ampproject_v0.js +34 -0
- package/extensions/ublock/web_accessible_resources/chartbeat.js +30 -0
- package/extensions/ublock/web_accessible_resources/click2load.html +28 -0
- package/extensions/ublock/web_accessible_resources/doubleclick_instream_ad_status.js +1 -0
- package/extensions/ublock/web_accessible_resources/empty +0 -0
- package/extensions/ublock/web_accessible_resources/epicker-ui.html +76 -0
- package/extensions/ublock/web_accessible_resources/fingerprint2.js +55 -0
- package/extensions/ublock/web_accessible_resources/fingerprint3.js +45 -0
- package/extensions/ublock/web_accessible_resources/google-analytics_analytics.js +110 -0
- package/extensions/ublock/web_accessible_resources/google-analytics_cx_api.js +36 -0
- package/extensions/ublock/web_accessible_resources/google-analytics_ga.js +130 -0
- package/extensions/ublock/web_accessible_resources/google-analytics_inpage_linkid.js +28 -0
- package/extensions/ublock/web_accessible_resources/google-ima.js +855 -0
- package/extensions/ublock/web_accessible_resources/googlesyndication_adsbygoogle.js +56 -0
- package/extensions/ublock/web_accessible_resources/googletagmanager_gtm.js +43 -0
- package/extensions/ublock/web_accessible_resources/googletagservices_gpt.js +153 -0
- package/extensions/ublock/web_accessible_resources/hd-main.js +46 -0
- package/extensions/ublock/web_accessible_resources/ligatus_angular-tag.js +29 -0
- package/extensions/ublock/web_accessible_resources/monkeybroker.js +43 -0
- package/extensions/ublock/web_accessible_resources/mxpnl_mixpanel.js +51 -0
- package/extensions/ublock/web_accessible_resources/nobab.js +87 -0
- package/extensions/ublock/web_accessible_resources/nobab2.js +42 -0
- package/extensions/ublock/web_accessible_resources/noeval-silent.js +28 -0
- package/extensions/ublock/web_accessible_resources/noeval.js +30 -0
- package/extensions/ublock/web_accessible_resources/nofab.js +67 -0
- package/extensions/ublock/web_accessible_resources/noop-0.1s.mp3 +0 -0
- package/extensions/ublock/web_accessible_resources/noop-0.5s.mp3 +0 -0
- package/extensions/ublock/web_accessible_resources/noop-1s.mp4 +0 -0
- package/extensions/ublock/web_accessible_resources/noop-vmap1.0.xml +1 -0
- package/extensions/ublock/web_accessible_resources/noop.css +1 -0
- package/extensions/ublock/web_accessible_resources/noop.html +5 -0
- package/extensions/ublock/web_accessible_resources/noop.js +3 -0
- package/extensions/ublock/web_accessible_resources/noop.json +1 -0
- package/extensions/ublock/web_accessible_resources/noop.txt +1 -0
- package/extensions/ublock/web_accessible_resources/outbrain-widget.js +72 -0
- package/extensions/ublock/web_accessible_resources/popads-dummy.js +30 -0
- package/extensions/ublock/web_accessible_resources/popads.js +40 -0
- package/extensions/ublock/web_accessible_resources/prebid-ads.js +26 -0
- package/extensions/ublock/web_accessible_resources/scorecardresearch_beacon.js +31 -0
- package/extensions/ublock/whitelist.html +63 -0
- package/external/.gitkeep +0 -0
- package/fonts/Calibri Bold Italic.ttf +0 -0
- package/fonts/Calibri Bold.TTF +0 -0
- package/fonts/Calibri Italic.ttf +0 -0
- package/fonts/Calibri Light Italic.ttf +0 -0
- package/fonts/Calibri Light.ttf +0 -0
- package/fonts/Calibri Regular.ttf +0 -0
- package/fonts/Emoji.ttf +0 -0
- package/fonts/SegoeUI-Bold.ttf +0 -0
- package/fonts/SegoeUI-Light.ttf +0 -0
- package/fonts/SegoeUI-Regular.ttf +0 -0
- package/fonts/SegoeUI-Semibold.ttf +0 -0
- package/fonts/SegoeUI-Semilight.ttf +0 -0
- package/fonts/Tahoma Bold.ttf +0 -0
- package/fonts/Tahoma.ttf +0 -0
- package/fonts/fonts.conf +21 -0
- package/package.json +177 -0
- package/scripts/build-function.js +18 -0
- package/scripts/build-open-api.js +274 -0
- package/scripts/build-schemas.js +86 -0
- package/scripts/build-selectors.js +36 -0
- package/scripts/clean.js +7 -0
- package/scripts/install-adblock.js +45 -0
- package/scripts/install-cdp-json.js +37 -0
- package/scripts/start.sh +30 -0
- package/scripts/test.sh +17 -0
- package/src/browserless.ts +253 -0
- package/src/browsers/cdp-chromium.ts +422 -0
- package/src/browsers/index.ts +296 -0
- package/src/browsers/playwright-chromium.ts +168 -0
- package/src/browsers/playwright-firefox.ts +161 -0
- package/src/browsers/playwright-webkit.ts +161 -0
- package/src/config.ts +426 -0
- package/src/constants.ts +4 -0
- package/src/exports.ts +23 -0
- package/src/file-system.ts +54 -0
- package/src/hooks.ts +37 -0
- package/src/http.ts +157 -0
- package/src/index.ts +41 -0
- package/src/limiter.spec.ts +365 -0
- package/src/limiter.ts +225 -0
- package/src/metrics.spec.ts +49 -0
- package/src/metrics.ts +108 -0
- package/src/mime-types.ts +332 -0
- package/src/monitoring.ts +53 -0
- package/src/routes/chromium/http/content-post.ts +238 -0
- package/src/routes/chromium/http/download-post.ts +162 -0
- package/src/routes/chromium/http/function-post.ts +98 -0
- package/src/routes/chromium/http/pdf-post.ts +234 -0
- package/src/routes/chromium/http/performance.ts +71 -0
- package/src/routes/chromium/http/scrape-post.ts +439 -0
- package/src/routes/chromium/http/screenshot-post.ts +262 -0
- package/src/routes/chromium/tests/content.spec.ts +340 -0
- package/src/routes/chromium/tests/download.spec.ts +77 -0
- package/src/routes/chromium/tests/function.spec.ts +279 -0
- package/src/routes/chromium/tests/pdf.spec.ts +375 -0
- package/src/routes/chromium/tests/performance.spec.ts +155 -0
- package/src/routes/chromium/tests/scrape.spec.ts +414 -0
- package/src/routes/chromium/tests/screenshot.spec.ts +387 -0
- package/src/routes/chromium/tests/websocket.spec.ts +407 -0
- package/src/routes/chromium/utils/function/client.ts +99 -0
- package/src/routes/chromium/utils/function/handler.ts +172 -0
- package/src/routes/chromium/utils/performance/child.ts +38 -0
- package/src/routes/chromium/utils/performance/main.ts +90 -0
- package/src/routes/chromium/utils/performance/types.ts +24 -0
- package/src/routes/chromium/ws/browser.ts +31 -0
- package/src/routes/chromium/ws/cdp-chromium.ts +31 -0
- package/src/routes/chromium/ws/page.ts +31 -0
- package/src/routes/chromium/ws/playwright-chromium.ts +44 -0
- package/src/routes/firefox/tests/websocket.spec.ts +146 -0
- package/src/routes/firefox/ws/playwright-firefox.ts +44 -0
- package/src/routes/management/http/config-get.ts +82 -0
- package/src/routes/management/http/metrics-get.ts +43 -0
- package/src/routes/management/http/metrics-total-get.ts +89 -0
- package/src/routes/management/http/sessions-get.ts +39 -0
- package/src/routes/management/http/static-get.ts +109 -0
- package/src/routes/management/tests/management.spec.ts +71 -0
- package/src/routes/webkit/tests/websocket.spec.ts +146 -0
- package/src/routes/webkit/ws/playwright-webkit.ts +44 -0
- package/src/server.ts +609 -0
- package/src/shim.spec.ts +154 -0
- package/src/shim.ts +78 -0
- package/src/types.ts +470 -0
- package/src/utils.ts +787 -0
- package/src/webhooks.ts +50 -0
- package/static/docs/browserless-logo.png +0 -0
- package/static/docs/docs.js +2 -0
- package/static/docs/index.html +71 -0
- package/static/docs/swagger.json +4232 -0
- package/static/favicon-32x32.png +0 -0
- package/static/function/client.js +31623 -0
- package/static/function/index.html +12 -0
- package/tsconfig.json +31 -0
|
@@ -0,0 +1,1260 @@
|
|
|
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
|
+
/* globals browser */
|
|
23
|
+
|
|
24
|
+
'use strict';
|
|
25
|
+
|
|
26
|
+
/******************************************************************************/
|
|
27
|
+
|
|
28
|
+
import htmlFilteringEngine from './html-filtering.js';
|
|
29
|
+
import httpheaderFilteringEngine from './httpheader-filtering.js';
|
|
30
|
+
import logger from './logger.js';
|
|
31
|
+
import scriptletFilteringEngine from './scriptlet-filtering.js';
|
|
32
|
+
import staticNetFilteringEngine from './static-net-filtering.js';
|
|
33
|
+
import textEncode from './text-encode.js';
|
|
34
|
+
import µb from './background.js';
|
|
35
|
+
import * as sfp from './static-filtering-parser.js';
|
|
36
|
+
import * as fc from './filtering-context.js';
|
|
37
|
+
import { isNetworkURI } from './uri-utils.js';
|
|
38
|
+
|
|
39
|
+
import {
|
|
40
|
+
sessionFirewall,
|
|
41
|
+
sessionSwitches,
|
|
42
|
+
sessionURLFiltering,
|
|
43
|
+
} from './filtering-engines.js';
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/******************************************************************************/
|
|
47
|
+
|
|
48
|
+
// Platform-specific behavior.
|
|
49
|
+
|
|
50
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/42
|
|
51
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1376932
|
|
52
|
+
// Add proper version number detection once issue is fixed in Firefox.
|
|
53
|
+
let dontCacheResponseHeaders =
|
|
54
|
+
vAPI.webextFlavor.soup.has('firefox');
|
|
55
|
+
|
|
56
|
+
// The real actual webextFlavor value may not be set in stone, so listen
|
|
57
|
+
// for possible future changes.
|
|
58
|
+
window.addEventListener('webextFlavor', function() {
|
|
59
|
+
dontCacheResponseHeaders =
|
|
60
|
+
vAPI.webextFlavor.soup.has('firefox');
|
|
61
|
+
}, { once: true });
|
|
62
|
+
|
|
63
|
+
/******************************************************************************/
|
|
64
|
+
|
|
65
|
+
const patchLocalRedirectURL = url => url.charCodeAt(0) === 0x2F /* '/' */
|
|
66
|
+
? vAPI.getURL(url)
|
|
67
|
+
: url;
|
|
68
|
+
|
|
69
|
+
/******************************************************************************/
|
|
70
|
+
|
|
71
|
+
// Intercept and filter web requests.
|
|
72
|
+
|
|
73
|
+
const onBeforeRequest = function(details) {
|
|
74
|
+
const fctxt = µb.filteringContext.fromWebrequestDetails(details);
|
|
75
|
+
|
|
76
|
+
// Special handling for root document.
|
|
77
|
+
// https://github.com/chrisaljoudi/uBlock/issues/1001
|
|
78
|
+
// This must be executed regardless of whether the request is
|
|
79
|
+
// behind-the-scene
|
|
80
|
+
if ( fctxt.itype === fctxt.MAIN_FRAME ) {
|
|
81
|
+
return onBeforeRootFrameRequest(fctxt);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Special treatment: behind-the-scene requests
|
|
85
|
+
const tabId = details.tabId;
|
|
86
|
+
if ( tabId < 0 ) {
|
|
87
|
+
return onBeforeBehindTheSceneRequest(fctxt);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Lookup the page store associated with this tab id.
|
|
91
|
+
let pageStore = µb.pageStoreFromTabId(tabId);
|
|
92
|
+
if ( pageStore === null ) {
|
|
93
|
+
const tabContext = µb.tabContextManager.mustLookup(tabId);
|
|
94
|
+
if ( tabContext.tabId < 0 ) {
|
|
95
|
+
return onBeforeBehindTheSceneRequest(fctxt);
|
|
96
|
+
}
|
|
97
|
+
vAPI.tabs.onNavigation({ tabId, frameId: 0, url: tabContext.rawURL });
|
|
98
|
+
pageStore = µb.pageStoreFromTabId(tabId);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const result = pageStore.filterRequest(fctxt);
|
|
102
|
+
|
|
103
|
+
pageStore.journalAddRequest(fctxt, result);
|
|
104
|
+
|
|
105
|
+
if ( logger.enabled ) {
|
|
106
|
+
fctxt.setRealm('network').toLogger();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Redirected
|
|
110
|
+
|
|
111
|
+
if ( fctxt.redirectURL !== undefined ) {
|
|
112
|
+
return { redirectUrl: patchLocalRedirectURL(fctxt.redirectURL) };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Not redirected
|
|
116
|
+
|
|
117
|
+
// Blocked
|
|
118
|
+
if ( result === 1 ) {
|
|
119
|
+
return { cancel: true };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Not blocked
|
|
123
|
+
if (
|
|
124
|
+
fctxt.itype === fctxt.SUB_FRAME &&
|
|
125
|
+
details.parentFrameId !== -1 &&
|
|
126
|
+
details.aliasURL === undefined
|
|
127
|
+
) {
|
|
128
|
+
pageStore.setFrameURL(details);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if ( result === 2 ) {
|
|
132
|
+
return { cancel: false };
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/******************************************************************************/
|
|
137
|
+
|
|
138
|
+
const onBeforeRootFrameRequest = function(fctxt) {
|
|
139
|
+
const requestURL = fctxt.url;
|
|
140
|
+
|
|
141
|
+
// Special handling for root document.
|
|
142
|
+
// https://github.com/chrisaljoudi/uBlock/issues/1001
|
|
143
|
+
// This must be executed regardless of whether the request is
|
|
144
|
+
// behind-the-scene
|
|
145
|
+
const requestHostname = fctxt.getHostname();
|
|
146
|
+
let result = 0;
|
|
147
|
+
let logData;
|
|
148
|
+
|
|
149
|
+
// If the site is whitelisted, disregard strict blocking
|
|
150
|
+
const trusted = µb.getNetFilteringSwitch(requestURL) === false;
|
|
151
|
+
if ( trusted ) {
|
|
152
|
+
result = 2;
|
|
153
|
+
if ( logger.enabled ) {
|
|
154
|
+
logData = { engine: 'u', result: 2, raw: 'whitelisted' };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Permanently unrestricted?
|
|
159
|
+
if (
|
|
160
|
+
result === 0 &&
|
|
161
|
+
sessionSwitches.evaluateZ('no-strict-blocking', requestHostname)
|
|
162
|
+
) {
|
|
163
|
+
result = 2;
|
|
164
|
+
if ( logger.enabled ) {
|
|
165
|
+
logData = {
|
|
166
|
+
engine: 'u',
|
|
167
|
+
result: 2,
|
|
168
|
+
raw: `no-strict-blocking: ${sessionSwitches.z} true`
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Temporarily whitelisted?
|
|
174
|
+
if ( result === 0 && strictBlockBypasser.isBypassed(requestHostname) ) {
|
|
175
|
+
result = 2;
|
|
176
|
+
if ( logger.enabled ) {
|
|
177
|
+
logData = {
|
|
178
|
+
engine: 'u',
|
|
179
|
+
result: 2,
|
|
180
|
+
raw: 'no-strict-blocking: true (temporary)'
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Static filtering
|
|
186
|
+
if ( result === 0 ) {
|
|
187
|
+
({ result, logData } = shouldStrictBlock(fctxt, logger.enabled));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const pageStore = µb.bindTabToPageStore(fctxt.tabId, 'beforeRequest');
|
|
191
|
+
if ( pageStore !== null ) {
|
|
192
|
+
pageStore.journalAddRootFrame('uncommitted', requestURL);
|
|
193
|
+
pageStore.journalAddRequest(fctxt, result);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if ( logger.enabled ) {
|
|
197
|
+
fctxt.setFilter(logData);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/760
|
|
201
|
+
// Redirect non-blocked request?
|
|
202
|
+
if ( result !== 1 && trusted === false && pageStore !== null ) {
|
|
203
|
+
pageStore.redirectNonBlockedRequest(fctxt);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if ( logger.enabled ) {
|
|
207
|
+
fctxt.setRealm('network').toLogger();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Redirected
|
|
211
|
+
|
|
212
|
+
if ( fctxt.redirectURL !== undefined ) {
|
|
213
|
+
return { redirectUrl: patchLocalRedirectURL(fctxt.redirectURL) };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Not blocked
|
|
217
|
+
|
|
218
|
+
if ( result !== 1 ) { return; }
|
|
219
|
+
|
|
220
|
+
// No log data means no strict blocking (because we need to report why
|
|
221
|
+
// the blocking occurs.
|
|
222
|
+
if ( logData === undefined ) { return; }
|
|
223
|
+
|
|
224
|
+
// Blocked
|
|
225
|
+
|
|
226
|
+
const query = encodeURIComponent(JSON.stringify({
|
|
227
|
+
url: requestURL,
|
|
228
|
+
hn: requestHostname,
|
|
229
|
+
dn: fctxt.getDomain() || requestHostname,
|
|
230
|
+
fs: logData.raw
|
|
231
|
+
}));
|
|
232
|
+
|
|
233
|
+
vAPI.tabs.replace(
|
|
234
|
+
fctxt.tabId,
|
|
235
|
+
vAPI.getURL('document-blocked.html?details=') + query
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
return { cancel: true };
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/******************************************************************************/
|
|
242
|
+
|
|
243
|
+
// Strict blocking through static filtering
|
|
244
|
+
//
|
|
245
|
+
// https://github.com/chrisaljoudi/uBlock/issues/1128
|
|
246
|
+
// Do not block if the match begins after the hostname,
|
|
247
|
+
// except when the filter is specifically of type `other`.
|
|
248
|
+
// https://github.com/gorhill/uBlock/issues/490
|
|
249
|
+
// Removing this for the time being, will need a new, dedicated type.
|
|
250
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/1501
|
|
251
|
+
// Support explicit exception filters.
|
|
252
|
+
//
|
|
253
|
+
// Let result of match for specific `document` type be `rs`
|
|
254
|
+
// Let result of match for no specific type be `rg` *after* going through
|
|
255
|
+
// confirmation necessary for implicit matches
|
|
256
|
+
// Let `important` be `i`
|
|
257
|
+
// Let final result be logical combination of `rs` and `rg` as follow:
|
|
258
|
+
//
|
|
259
|
+
// | rs |
|
|
260
|
+
// +--------+--------+--------+--------|
|
|
261
|
+
// | 0 | 1 | 1i | 2 |
|
|
262
|
+
// --------+--------+--------+--------+--------+--------|
|
|
263
|
+
// | 0 | rg | rs | rs | rs |
|
|
264
|
+
// rg | 1 | rg | rs | rs | rs |
|
|
265
|
+
// | 1i | rg | rg | rs | rg |
|
|
266
|
+
// | 2 | rg | rg | rs | rs |
|
|
267
|
+
// --------+--------+--------+--------+--------+--------+
|
|
268
|
+
|
|
269
|
+
const shouldStrictBlock = function(fctxt, loggerEnabled) {
|
|
270
|
+
const snfe = staticNetFilteringEngine;
|
|
271
|
+
|
|
272
|
+
// Explicit filtering: `document` option
|
|
273
|
+
const rs = snfe.matchRequest(fctxt, 0b0011);
|
|
274
|
+
const is = rs === 1 && snfe.isBlockImportant();
|
|
275
|
+
let lds;
|
|
276
|
+
if ( rs !== 0 || loggerEnabled ) {
|
|
277
|
+
lds = snfe.toLogData();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// | rs |
|
|
281
|
+
// +--------+--------+--------+--------|
|
|
282
|
+
// | 0 | 1 | 1i | 2 |
|
|
283
|
+
// --------+--------+--------+--------+--------+--------|
|
|
284
|
+
// | 0 | rg | rs | x | rs |
|
|
285
|
+
// rg | 1 | rg | rs | x | rs |
|
|
286
|
+
// | 1i | rg | rg | x | rg |
|
|
287
|
+
// | 2 | rg | rg | x | rs |
|
|
288
|
+
// --------+--------+--------+--------+--------+--------+
|
|
289
|
+
if ( rs === 1 && is ) {
|
|
290
|
+
return { result: rs, logData: lds };
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Implicit filtering: no `document` option
|
|
294
|
+
fctxt.type = 'no_type';
|
|
295
|
+
let rg = snfe.matchRequest(fctxt, 0b0011);
|
|
296
|
+
fctxt.type = 'main_frame';
|
|
297
|
+
const ig = rg === 1 && snfe.isBlockImportant();
|
|
298
|
+
let ldg;
|
|
299
|
+
if ( rg !== 0 || loggerEnabled ) {
|
|
300
|
+
ldg = snfe.toLogData();
|
|
301
|
+
if ( rg === 1 && validateStrictBlock(fctxt, ldg) === false ) {
|
|
302
|
+
rg = 0; ldg = undefined;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// | rs |
|
|
307
|
+
// +--------+--------+--------+--------|
|
|
308
|
+
// | 0 | 1 | 1i | 2 |
|
|
309
|
+
// --------+--------+--------+--------+--------+--------|
|
|
310
|
+
// | 0 | x | rs | - | rs |
|
|
311
|
+
// rg | 1 | x | rs | - | rs |
|
|
312
|
+
// | 1i | x | x | - | x |
|
|
313
|
+
// | 2 | x | x | - | rs |
|
|
314
|
+
// --------+--------+--------+--------+--------+--------+
|
|
315
|
+
if ( rs === 0 || rg === 1 && ig || rg === 2 && rs !== 2 ) {
|
|
316
|
+
return { result: rg, logData: ldg };
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// | rs |
|
|
320
|
+
// +--------+--------+--------+--------|
|
|
321
|
+
// | 0 | 1 | 1i | 2 |
|
|
322
|
+
// --------+--------+--------+--------+--------+--------|
|
|
323
|
+
// | 0 | - | x | - | x |
|
|
324
|
+
// rg | 1 | - | x | - | x |
|
|
325
|
+
// | 1i | - | - | - | - |
|
|
326
|
+
// | 2 | - | - | - | x |
|
|
327
|
+
// --------+--------+--------+--------+--------+--------+
|
|
328
|
+
return { result: rs, logData: lds };
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
/******************************************************************************/
|
|
332
|
+
|
|
333
|
+
// https://github.com/gorhill/uBlock/issues/3208
|
|
334
|
+
// Mind case insensitivity.
|
|
335
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/1147
|
|
336
|
+
// Do not strict-block if the filter pattern does not contain at least one
|
|
337
|
+
// token character.
|
|
338
|
+
|
|
339
|
+
const validateStrictBlock = function(fctxt, logData) {
|
|
340
|
+
if ( typeof logData.regex !== 'string' ) { return false; }
|
|
341
|
+
if ( typeof logData.raw === 'string' && /\w/.test(logData.raw) === false ) {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
const url = fctxt.url;
|
|
345
|
+
const re = new RegExp(logData.regex, 'i');
|
|
346
|
+
const match = re.exec(url.toLowerCase());
|
|
347
|
+
if ( match === null ) { return false; }
|
|
348
|
+
|
|
349
|
+
// https://github.com/chrisaljoudi/uBlock/issues/1128
|
|
350
|
+
// https://github.com/chrisaljoudi/uBlock/issues/1212
|
|
351
|
+
// Verify that the end of the match is anchored to the end of the
|
|
352
|
+
// hostname.
|
|
353
|
+
// https://github.com/uBlockOrigin/uAssets/issues/7619#issuecomment-653010310
|
|
354
|
+
// Also match FQDN.
|
|
355
|
+
const hostname = fctxt.getHostname();
|
|
356
|
+
const hnpos = url.indexOf(hostname);
|
|
357
|
+
const hnlen = hostname.length;
|
|
358
|
+
const end = match.index + match[0].length - hnpos - hnlen;
|
|
359
|
+
return end === 0 || end === 1 ||
|
|
360
|
+
end === 2 && url.charCodeAt(hnpos + hnlen) === 0x2E /* '.' */;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
/******************************************************************************/
|
|
364
|
+
|
|
365
|
+
// Intercept and filter behind-the-scene requests.
|
|
366
|
+
|
|
367
|
+
const onBeforeBehindTheSceneRequest = function(fctxt) {
|
|
368
|
+
const pageStore = µb.pageStoreFromTabId(fctxt.tabId);
|
|
369
|
+
if ( pageStore === null ) { return; }
|
|
370
|
+
|
|
371
|
+
// https://github.com/gorhill/uBlock/issues/3150
|
|
372
|
+
// Ability to globally block CSP reports MUST also apply to
|
|
373
|
+
// behind-the-scene network requests.
|
|
374
|
+
|
|
375
|
+
let result = 0;
|
|
376
|
+
|
|
377
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/339
|
|
378
|
+
// Need to also test against `-scheme` since tabOrigin is normalized.
|
|
379
|
+
// Not especially elegant but for now this accomplishes the purpose of
|
|
380
|
+
// not dealing with network requests fired from a synthetic scope,
|
|
381
|
+
// that is unless advanced user mode is enabled.
|
|
382
|
+
|
|
383
|
+
if (
|
|
384
|
+
fctxt.tabOrigin.endsWith('-scheme') === false &&
|
|
385
|
+
isNetworkURI(fctxt.tabOrigin) ||
|
|
386
|
+
µb.userSettings.advancedUserEnabled ||
|
|
387
|
+
fctxt.itype === fctxt.CSP_REPORT
|
|
388
|
+
) {
|
|
389
|
+
result = pageStore.filterRequest(fctxt);
|
|
390
|
+
|
|
391
|
+
// The "any-tab" scope is not whitelist-able, and in such case we must
|
|
392
|
+
// use the origin URL as the scope. Most such requests aren't going to
|
|
393
|
+
// be blocked, so we test for whitelisting and modify the result only
|
|
394
|
+
// when the request is being blocked.
|
|
395
|
+
//
|
|
396
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/1478
|
|
397
|
+
// Also remove potential redirection when request is to be
|
|
398
|
+
// whitelisted.
|
|
399
|
+
if (
|
|
400
|
+
result === 1 &&
|
|
401
|
+
µb.getNetFilteringSwitch(fctxt.tabOrigin) === false
|
|
402
|
+
) {
|
|
403
|
+
result = 2;
|
|
404
|
+
fctxt.redirectURL = undefined;
|
|
405
|
+
fctxt.filter = { engine: 'u', result: 2, raw: 'whitelisted' };
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/1204
|
|
410
|
+
onBeforeBehindTheSceneRequest.journalAddRequest(fctxt, result);
|
|
411
|
+
|
|
412
|
+
if ( logger.enabled ) {
|
|
413
|
+
fctxt.setRealm('network').toLogger();
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Redirected
|
|
417
|
+
|
|
418
|
+
if ( fctxt.redirectURL !== undefined ) {
|
|
419
|
+
return { redirectUrl: patchLocalRedirectURL(fctxt.redirectURL) };
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// Blocked?
|
|
423
|
+
|
|
424
|
+
if ( result === 1 ) {
|
|
425
|
+
return { cancel: true };
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/1204
|
|
430
|
+
// Report the tabless network requests to all page stores matching the
|
|
431
|
+
// document origin. This is an approximation, there is unfortunately no
|
|
432
|
+
// way to know for sure which exact page triggered a tabless network
|
|
433
|
+
// request.
|
|
434
|
+
|
|
435
|
+
{
|
|
436
|
+
const pageStores = new Set();
|
|
437
|
+
let hostname = '';
|
|
438
|
+
let pageStoresToken = 0;
|
|
439
|
+
|
|
440
|
+
const reset = function() {
|
|
441
|
+
hostname = '';
|
|
442
|
+
pageStores.clear();
|
|
443
|
+
pageStoresToken = 0;
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
const gc = ( ) => {
|
|
447
|
+
if ( pageStoresToken !== µb.pageStoresToken ) { return reset(); }
|
|
448
|
+
gcTimer.on(30011);
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
const gcTimer = vAPI.defer.create(gc);
|
|
452
|
+
|
|
453
|
+
onBeforeBehindTheSceneRequest.journalAddRequest = (fctxt, result) => {
|
|
454
|
+
const docHostname = fctxt.getDocHostname();
|
|
455
|
+
if (
|
|
456
|
+
docHostname !== hostname ||
|
|
457
|
+
pageStoresToken !== µb.pageStoresToken
|
|
458
|
+
) {
|
|
459
|
+
hostname = docHostname;
|
|
460
|
+
pageStores.clear();
|
|
461
|
+
for ( const pageStore of µb.pageStores.values() ) {
|
|
462
|
+
if ( pageStore.tabHostname !== docHostname ) { continue; }
|
|
463
|
+
pageStores.add(pageStore);
|
|
464
|
+
}
|
|
465
|
+
pageStoresToken = µb.pageStoresToken;
|
|
466
|
+
gcTimer.offon(30011);
|
|
467
|
+
}
|
|
468
|
+
for ( const pageStore of pageStores ) {
|
|
469
|
+
pageStore.journalAddRequest(fctxt, result);
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/******************************************************************************/
|
|
475
|
+
|
|
476
|
+
// To handle:
|
|
477
|
+
// - Media elements larger than n kB
|
|
478
|
+
// - Scriptlet injection (requires ability to modify response body)
|
|
479
|
+
// - HTML filtering (requires ability to modify response body)
|
|
480
|
+
// - CSP injection
|
|
481
|
+
|
|
482
|
+
const onHeadersReceived = function(details) {
|
|
483
|
+
|
|
484
|
+
const fctxt = µb.filteringContext.fromWebrequestDetails(details);
|
|
485
|
+
const isRootDoc = fctxt.itype === fctxt.MAIN_FRAME;
|
|
486
|
+
|
|
487
|
+
let pageStore = µb.pageStoreFromTabId(fctxt.tabId);
|
|
488
|
+
if ( pageStore === null ) {
|
|
489
|
+
if ( isRootDoc === false ) { return; }
|
|
490
|
+
pageStore = µb.bindTabToPageStore(fctxt.tabId, 'beforeRequest');
|
|
491
|
+
}
|
|
492
|
+
if ( pageStore.getNetFilteringSwitch(fctxt) === false ) { return; }
|
|
493
|
+
|
|
494
|
+
if ( fctxt.itype === fctxt.IMAGE || fctxt.itype === fctxt.MEDIA ) {
|
|
495
|
+
const result = foilLargeMediaElement(details, fctxt, pageStore);
|
|
496
|
+
if ( result !== undefined ) { return result; }
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// Keep in mind response headers will be modified in-place if needed, so
|
|
500
|
+
// `details.responseHeaders` will always point to the modified response
|
|
501
|
+
// headers.
|
|
502
|
+
const { responseHeaders } = details;
|
|
503
|
+
if ( Array.isArray(responseHeaders) === false ) { return; }
|
|
504
|
+
|
|
505
|
+
if ( isRootDoc === false ) {
|
|
506
|
+
const result = pageStore.filterOnHeaders(fctxt, responseHeaders);
|
|
507
|
+
if ( result !== 0 ) {
|
|
508
|
+
if ( logger.enabled ) {
|
|
509
|
+
fctxt.setRealm('network').toLogger();
|
|
510
|
+
}
|
|
511
|
+
if ( result === 1 ) {
|
|
512
|
+
pageStore.journalAddRequest(fctxt, 1);
|
|
513
|
+
return { cancel: true };
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
const mime = mimeFromHeaders(responseHeaders);
|
|
519
|
+
|
|
520
|
+
// https://github.com/gorhill/uBlock/issues/2813
|
|
521
|
+
// Disable the blocking of large media elements if the document is itself
|
|
522
|
+
// a media element: the resource was not prevented from loading so no
|
|
523
|
+
// point to further block large media elements for the current document.
|
|
524
|
+
if ( isRootDoc ) {
|
|
525
|
+
if ( reMediaContentTypes.test(mime) ) {
|
|
526
|
+
pageStore.allowLargeMediaElementsUntil = 0;
|
|
527
|
+
// Fall-through: this could be an SVG document, which supports
|
|
528
|
+
// script tags.
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
if ( bodyFilterer.canFilter(fctxt, details) ) {
|
|
533
|
+
const jobs = [];
|
|
534
|
+
// `replace=` filter option
|
|
535
|
+
const replaceDirectives =
|
|
536
|
+
staticNetFilteringEngine.matchAndFetchModifiers(fctxt, 'replace');
|
|
537
|
+
if ( replaceDirectives ) {
|
|
538
|
+
jobs.push({
|
|
539
|
+
fn: textResponseFilterer,
|
|
540
|
+
args: [ replaceDirectives ],
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
// html filtering
|
|
544
|
+
if ( mime === 'text/html' || mime === 'application/xhtml+xml' ) {
|
|
545
|
+
const selectors = htmlFilteringEngine.retrieve(fctxt);
|
|
546
|
+
if ( selectors ) {
|
|
547
|
+
jobs.push({
|
|
548
|
+
fn: htmlResponseFilterer,
|
|
549
|
+
args: [ selectors ],
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
if ( jobs.length !== 0 ) {
|
|
554
|
+
bodyFilterer.doFilter(fctxt, jobs);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
let modifiedHeaders = false;
|
|
559
|
+
if ( httpheaderFilteringEngine.apply(fctxt, responseHeaders) === true ) {
|
|
560
|
+
modifiedHeaders = true;
|
|
561
|
+
}
|
|
562
|
+
if ( injectCSP(fctxt, pageStore, responseHeaders) === true ) {
|
|
563
|
+
modifiedHeaders = true;
|
|
564
|
+
}
|
|
565
|
+
if ( injectPP(fctxt, pageStore, responseHeaders) === true ) {
|
|
566
|
+
modifiedHeaders = true;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1376932
|
|
570
|
+
// Prevent document from being cached by the browser if we modified it,
|
|
571
|
+
// either through HTML filtering and/or modified response headers.
|
|
572
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/229
|
|
573
|
+
// Use `no-cache` instead of `no-cache, no-store, must-revalidate`, this
|
|
574
|
+
// allows Firefox's offline mode to work as expected.
|
|
575
|
+
if ( modifiedHeaders && dontCacheResponseHeaders ) {
|
|
576
|
+
const cacheControl = µb.hiddenSettings.cacheControlForFirefox1376932;
|
|
577
|
+
if ( cacheControl !== 'unset' ) {
|
|
578
|
+
let i = headerIndexFromName('cache-control', responseHeaders);
|
|
579
|
+
if ( i !== -1 ) {
|
|
580
|
+
responseHeaders[i].value = cacheControl;
|
|
581
|
+
} else {
|
|
582
|
+
responseHeaders.push({ name: 'Cache-Control', value: cacheControl });
|
|
583
|
+
}
|
|
584
|
+
modifiedHeaders = true;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
if ( modifiedHeaders ) {
|
|
589
|
+
return { responseHeaders };
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
const reMediaContentTypes = /^(?:audio|image|video)\//;
|
|
594
|
+
|
|
595
|
+
/******************************************************************************/
|
|
596
|
+
|
|
597
|
+
const mimeFromHeaders = headers => {
|
|
598
|
+
if ( Array.isArray(headers) === false ) { return ''; }
|
|
599
|
+
return mimeFromContentType(headerValueFromName('content-type', headers));
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
const mimeFromContentType = contentType => {
|
|
603
|
+
const match = reContentTypeMime.exec(contentType);
|
|
604
|
+
if ( match === null ) { return ''; }
|
|
605
|
+
return match[0].toLowerCase();
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
const reContentTypeMime = /^[^;]+/i;
|
|
609
|
+
|
|
610
|
+
/******************************************************************************/
|
|
611
|
+
|
|
612
|
+
function textResponseFilterer(session, directives) {
|
|
613
|
+
const applied = [];
|
|
614
|
+
for ( const directive of directives ) {
|
|
615
|
+
if ( directive.refs instanceof Object === false ) { continue; }
|
|
616
|
+
if ( directive.result !== 1 ) {
|
|
617
|
+
applied.push(directive);
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
const { refs } = directive;
|
|
621
|
+
if ( refs.$cache === null ) {
|
|
622
|
+
refs.$cache = sfp.parseReplaceValue(refs.value);
|
|
623
|
+
}
|
|
624
|
+
const cache = refs.$cache;
|
|
625
|
+
if ( cache === undefined ) { continue; }
|
|
626
|
+
cache.re.lastIndex = 0;
|
|
627
|
+
if ( cache.re.test(session.getString()) !== true ) { continue; }
|
|
628
|
+
cache.re.lastIndex = 0;
|
|
629
|
+
session.setString(session.getString().replace(
|
|
630
|
+
cache.re,
|
|
631
|
+
cache.replacement
|
|
632
|
+
));
|
|
633
|
+
applied.push(directive);
|
|
634
|
+
}
|
|
635
|
+
if ( applied.length === 0 ) { return; }
|
|
636
|
+
if ( logger.enabled !== true ) { return; }
|
|
637
|
+
session.setRealm('network')
|
|
638
|
+
.pushFilters(applied.map(a => a.logData()))
|
|
639
|
+
.toLogger();
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/******************************************************************************/
|
|
643
|
+
|
|
644
|
+
function htmlResponseFilterer(session, selectors) {
|
|
645
|
+
if ( htmlResponseFilterer.domParser === null ) {
|
|
646
|
+
htmlResponseFilterer.domParser = new DOMParser();
|
|
647
|
+
htmlResponseFilterer.xmlSerializer = new XMLSerializer();
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
const doc = htmlResponseFilterer.domParser.parseFromString(
|
|
651
|
+
session.getString(),
|
|
652
|
+
session.mime
|
|
653
|
+
);
|
|
654
|
+
|
|
655
|
+
if ( selectors === undefined ) { return; }
|
|
656
|
+
if ( htmlFilteringEngine.apply(doc, session, selectors) !== true ) { return; }
|
|
657
|
+
|
|
658
|
+
// https://stackoverflow.com/questions/6088972/get-doctype-of-an-html-as-string-with-javascript/10162353#10162353
|
|
659
|
+
const doctypeStr = [
|
|
660
|
+
doc.doctype instanceof Object ?
|
|
661
|
+
htmlResponseFilterer.xmlSerializer.serializeToString(doc.doctype) + '\n' :
|
|
662
|
+
'',
|
|
663
|
+
doc.documentElement.outerHTML,
|
|
664
|
+
].join('\n');
|
|
665
|
+
session.setString(doctypeStr);
|
|
666
|
+
}
|
|
667
|
+
htmlResponseFilterer.domParser = null;
|
|
668
|
+
htmlResponseFilterer.xmlSerializer = null;
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
/*******************************************************************************
|
|
672
|
+
|
|
673
|
+
The response body filterer is responsible for:
|
|
674
|
+
|
|
675
|
+
- Realize static network filter option `replace=`
|
|
676
|
+
- HTML filtering
|
|
677
|
+
|
|
678
|
+
**/
|
|
679
|
+
|
|
680
|
+
const bodyFilterer = (( ) => {
|
|
681
|
+
const sessions = new Map();
|
|
682
|
+
const reContentTypeCharset = /charset=['"]?([^'" ]+)/i;
|
|
683
|
+
const otherValidMimes = new Set([
|
|
684
|
+
'application/javascript',
|
|
685
|
+
'application/json',
|
|
686
|
+
'application/mpegurl',
|
|
687
|
+
'application/vnd.api+json',
|
|
688
|
+
'application/vnd.apple.mpegurl',
|
|
689
|
+
'application/vnd.apple.mpegurl.audio',
|
|
690
|
+
'application/x-mpegurl',
|
|
691
|
+
'application/xhtml+xml',
|
|
692
|
+
'application/xml',
|
|
693
|
+
'audio/mpegurl',
|
|
694
|
+
'audio/x-mpegurl',
|
|
695
|
+
]);
|
|
696
|
+
const BINARY_TYPES = fc.FONT | fc.IMAGE | fc.MEDIA | fc.WEBSOCKET;
|
|
697
|
+
const MAX_BUFFER_LENGTH = 3 * 1024 * 1024;
|
|
698
|
+
|
|
699
|
+
let textDecoder, textEncoder;
|
|
700
|
+
let mime = '';
|
|
701
|
+
let charset = '';
|
|
702
|
+
|
|
703
|
+
const contentTypeFromDetails = details => {
|
|
704
|
+
switch ( details.type ) {
|
|
705
|
+
case 'script':
|
|
706
|
+
return 'text/javascript; charset=utf-8';
|
|
707
|
+
case 'stylesheet':
|
|
708
|
+
return 'text/css';
|
|
709
|
+
default:
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
712
|
+
return '';
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
const charsetFromContentType = contentType => {
|
|
716
|
+
const match = reContentTypeCharset.exec(contentType);
|
|
717
|
+
if ( match === null ) { return; }
|
|
718
|
+
return match[1].toLowerCase();
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
const charsetFromMime = mime => {
|
|
722
|
+
switch ( mime ) {
|
|
723
|
+
case 'application/xml':
|
|
724
|
+
case 'application/xhtml+xml':
|
|
725
|
+
case 'text/html':
|
|
726
|
+
case 'text/css':
|
|
727
|
+
return;
|
|
728
|
+
default:
|
|
729
|
+
break;
|
|
730
|
+
}
|
|
731
|
+
return 'utf-8';
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
const charsetFromStream = bytes => {
|
|
735
|
+
if ( bytes.length < 3 ) { return; }
|
|
736
|
+
if ( bytes[0] === 0xEF && bytes[1] === 0xBB && bytes[2] === 0xBF ) {
|
|
737
|
+
return 'utf-8';
|
|
738
|
+
}
|
|
739
|
+
let i = -1;
|
|
740
|
+
while ( i < 65536 ) {
|
|
741
|
+
i += 1;
|
|
742
|
+
/* c */ if ( bytes[i+0] !== 0x63 ) { continue; }
|
|
743
|
+
/* h */ if ( bytes[i+1] !== 0x68 ) { continue; }
|
|
744
|
+
/* a */ if ( bytes[i+2] !== 0x61 ) { continue; }
|
|
745
|
+
/* r */ if ( bytes[i+3] !== 0x72 ) { continue; }
|
|
746
|
+
/* s */ if ( bytes[i+4] !== 0x73 ) { continue; }
|
|
747
|
+
/* e */ if ( bytes[i+5] !== 0x65 ) { continue; }
|
|
748
|
+
/* t */ if ( bytes[i+6] !== 0x74 ) { continue; }
|
|
749
|
+
break;
|
|
750
|
+
}
|
|
751
|
+
if ( (i - 40) >= 65536 ) { return; }
|
|
752
|
+
i += 8;
|
|
753
|
+
// find first alpha character
|
|
754
|
+
let j = -1;
|
|
755
|
+
while ( j < 8 ) {
|
|
756
|
+
j += 1;
|
|
757
|
+
const c = bytes[i+j];
|
|
758
|
+
if ( c >= 0x41 && c <= 0x5A ) { break; }
|
|
759
|
+
if ( c >= 0x61 && c <= 0x7A ) { break; }
|
|
760
|
+
}
|
|
761
|
+
if ( j === 8 ) { return; }
|
|
762
|
+
i += j;
|
|
763
|
+
// Collect characters until first non charset-name-character
|
|
764
|
+
const chars = [];
|
|
765
|
+
j = 0;
|
|
766
|
+
while ( j < 24 ) {
|
|
767
|
+
const c = bytes[i+j];
|
|
768
|
+
if ( c < 0x2D ) { break; }
|
|
769
|
+
if ( c > 0x2D && c < 0x30 ) { break; }
|
|
770
|
+
if ( c > 0x39 && c < 0x41 ) { break; }
|
|
771
|
+
if ( c > 0x5A && c < 0x61 ) { break; }
|
|
772
|
+
if ( c > 0x7A ) { break; }
|
|
773
|
+
chars.push(c);
|
|
774
|
+
j += 1;
|
|
775
|
+
}
|
|
776
|
+
if ( j === 20 ) { return; }
|
|
777
|
+
return String.fromCharCode(...chars).toLowerCase();
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
const streamClose = (session, buffer) => {
|
|
781
|
+
if ( buffer !== undefined ) {
|
|
782
|
+
session.stream.write(buffer);
|
|
783
|
+
} else if ( session.buffer !== undefined ) {
|
|
784
|
+
session.stream.write(session.buffer);
|
|
785
|
+
}
|
|
786
|
+
session.stream.close();
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
const onStreamData = function(ev) {
|
|
790
|
+
const session = sessions.get(this);
|
|
791
|
+
if ( session === undefined ) {
|
|
792
|
+
this.write(ev.data);
|
|
793
|
+
this.disconnect();
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
if ( this.status !== 'transferringdata' ) {
|
|
797
|
+
if ( this.status !== 'finishedtransferringdata' ) {
|
|
798
|
+
sessions.delete(this);
|
|
799
|
+
this.disconnect();
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
if ( session.buffer === null ) {
|
|
804
|
+
session.buffer = new Uint8Array(ev.data);
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
const buffer = new Uint8Array(
|
|
808
|
+
session.buffer.byteLength + ev.data.byteLength
|
|
809
|
+
);
|
|
810
|
+
buffer.set(session.buffer);
|
|
811
|
+
buffer.set(new Uint8Array(ev.data), session.buffer.byteLength);
|
|
812
|
+
session.buffer = buffer;
|
|
813
|
+
if ( session.buffer.length >= MAX_BUFFER_LENGTH ) {
|
|
814
|
+
sessions.delete(this);
|
|
815
|
+
this.write(session.buffer);
|
|
816
|
+
this.disconnect();
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
const onStreamStop = function() {
|
|
821
|
+
const session = sessions.get(this);
|
|
822
|
+
sessions.delete(this);
|
|
823
|
+
if ( session === undefined || session.buffer === null ) {
|
|
824
|
+
this.close();
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
if ( this.status !== 'finishedtransferringdata' ) { return; }
|
|
828
|
+
|
|
829
|
+
// If encoding is still unknown, try to extract from stream data
|
|
830
|
+
if ( session.charset === undefined ) {
|
|
831
|
+
const charsetFound = charsetFromStream(session.buffer);
|
|
832
|
+
if ( charsetFound === undefined ) { return streamClose(session); }
|
|
833
|
+
const charsetUsed = textEncode.normalizeCharset(charsetFound);
|
|
834
|
+
if ( charsetUsed === undefined ) { return streamClose(session); }
|
|
835
|
+
session.charset = charsetUsed;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
while ( session.jobs.length !== 0 ) {
|
|
839
|
+
const job = session.jobs.shift();
|
|
840
|
+
job.fn(session, ...job.args);
|
|
841
|
+
}
|
|
842
|
+
if ( session.modified !== true ) { return streamClose(session); }
|
|
843
|
+
|
|
844
|
+
if ( textEncoder === undefined ) {
|
|
845
|
+
textEncoder = new TextEncoder();
|
|
846
|
+
}
|
|
847
|
+
let encodedStream = textEncoder.encode(session.str);
|
|
848
|
+
|
|
849
|
+
if ( session.charset !== 'utf-8' ) {
|
|
850
|
+
encodedStream = textEncode.encode(session.charset, encodedStream);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
streamClose(session, encodedStream);
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
const onStreamError = function() {
|
|
857
|
+
sessions.delete(this);
|
|
858
|
+
};
|
|
859
|
+
|
|
860
|
+
return class Session extends µb.FilteringContext {
|
|
861
|
+
constructor(fctxt, mime, charset, jobs) {
|
|
862
|
+
super(fctxt);
|
|
863
|
+
this.stream = null;
|
|
864
|
+
this.buffer = null;
|
|
865
|
+
this.mime = mime;
|
|
866
|
+
this.charset = charset;
|
|
867
|
+
this.str = null;
|
|
868
|
+
this.modified = false;
|
|
869
|
+
this.jobs = jobs;
|
|
870
|
+
}
|
|
871
|
+
getString() {
|
|
872
|
+
if ( this.str !== null ) { return this.str; }
|
|
873
|
+
if ( textDecoder !== undefined ) {
|
|
874
|
+
if ( textDecoder.encoding !== this.charset ) {
|
|
875
|
+
textDecoder = undefined;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
if ( textDecoder === undefined ) {
|
|
879
|
+
textDecoder = new TextDecoder(this.charset);
|
|
880
|
+
}
|
|
881
|
+
this.str = textDecoder.decode(this.buffer);
|
|
882
|
+
return this.str;
|
|
883
|
+
}
|
|
884
|
+
setString(s) {
|
|
885
|
+
this.str = s;
|
|
886
|
+
this.modified = true;
|
|
887
|
+
}
|
|
888
|
+
static doFilter(fctxt, jobs) {
|
|
889
|
+
if ( jobs.length === 0 ) { return; }
|
|
890
|
+
const session = new Session(fctxt, mime, charset, jobs);
|
|
891
|
+
session.stream = browser.webRequest.filterResponseData(session.id);
|
|
892
|
+
session.stream.ondata = onStreamData;
|
|
893
|
+
session.stream.onstop = onStreamStop;
|
|
894
|
+
session.stream.onerror = onStreamError;
|
|
895
|
+
sessions.set(session.stream, session);
|
|
896
|
+
}
|
|
897
|
+
static canFilter(fctxt, details) {
|
|
898
|
+
if ( µb.canFilterResponseData !== true ) { return; }
|
|
899
|
+
|
|
900
|
+
if ( (fctxt.itype & BINARY_TYPES) !== 0 ) { return; }
|
|
901
|
+
|
|
902
|
+
if ( fctxt.method !== fc.METHOD_GET ) {
|
|
903
|
+
if ( fctxt.method !== fc.METHOD_POST ) {
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
// https://github.com/gorhill/uBlock/issues/3478
|
|
909
|
+
const statusCode = details.statusCode || 0;
|
|
910
|
+
if ( statusCode === 0 ) { return; }
|
|
911
|
+
|
|
912
|
+
const hostname = fctxt.getHostname();
|
|
913
|
+
if ( hostname === '' ) { return; }
|
|
914
|
+
|
|
915
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1426789
|
|
916
|
+
const headers = details.responseHeaders;
|
|
917
|
+
const disposition = headerValueFromName('content-disposition', headers);
|
|
918
|
+
if ( disposition !== '' ) {
|
|
919
|
+
if ( disposition.startsWith('inline') === false ) { return; }
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
mime = 'text/plain';
|
|
923
|
+
charset = 'utf-8';
|
|
924
|
+
const contentType = headerValueFromName('content-type', headers) ||
|
|
925
|
+
contentTypeFromDetails(details);
|
|
926
|
+
if ( contentType !== '' ) {
|
|
927
|
+
mime = mimeFromContentType(contentType);
|
|
928
|
+
if ( mime === undefined ) { return; }
|
|
929
|
+
if ( mime.startsWith('text/') === false ) {
|
|
930
|
+
if ( otherValidMimes.has(mime) === false ) { return; }
|
|
931
|
+
}
|
|
932
|
+
charset = charsetFromContentType(contentType);
|
|
933
|
+
if ( charset !== undefined ) {
|
|
934
|
+
charset = textEncode.normalizeCharset(charset);
|
|
935
|
+
if ( charset === undefined ) { return; }
|
|
936
|
+
} else {
|
|
937
|
+
charset = charsetFromMime(mime);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
return true;
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
})();
|
|
945
|
+
|
|
946
|
+
/******************************************************************************/
|
|
947
|
+
|
|
948
|
+
const injectCSP = function(fctxt, pageStore, responseHeaders) {
|
|
949
|
+
const cspSubsets = [];
|
|
950
|
+
const requestType = fctxt.type;
|
|
951
|
+
|
|
952
|
+
// Start collecting policies >>>>>>>>
|
|
953
|
+
|
|
954
|
+
// ======== built-in policies
|
|
955
|
+
|
|
956
|
+
const builtinDirectives = [];
|
|
957
|
+
|
|
958
|
+
if ( pageStore.filterScripting(fctxt, true) === 1 ) {
|
|
959
|
+
builtinDirectives.push(µb.cspNoScripting);
|
|
960
|
+
if ( logger.enabled ) {
|
|
961
|
+
fctxt.setRealm('network').setType('scripting').toLogger();
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/422
|
|
965
|
+
// We need to derive a special context for filtering `inline-script`,
|
|
966
|
+
// as the embedding document for this "resource" will always be the
|
|
967
|
+
// frame itself, not that of the parent of the frame.
|
|
968
|
+
else {
|
|
969
|
+
const fctxt2 = fctxt.duplicate();
|
|
970
|
+
fctxt2.type = 'inline-script';
|
|
971
|
+
fctxt2.setDocOriginFromURL(fctxt.url);
|
|
972
|
+
const result = pageStore.filterRequest(fctxt2);
|
|
973
|
+
if ( result === 1 ) {
|
|
974
|
+
builtinDirectives.push(µb.cspNoInlineScript);
|
|
975
|
+
}
|
|
976
|
+
if ( result === 2 && logger.enabled ) {
|
|
977
|
+
fctxt2.setRealm('network').toLogger();
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
// https://github.com/gorhill/uBlock/issues/1539
|
|
982
|
+
// - Use a CSP to also forbid inline fonts if remote fonts are blocked.
|
|
983
|
+
fctxt.type = 'inline-font';
|
|
984
|
+
if ( pageStore.filterRequest(fctxt) === 1 ) {
|
|
985
|
+
builtinDirectives.push(µb.cspNoInlineFont);
|
|
986
|
+
if ( logger.enabled ) {
|
|
987
|
+
fctxt.setRealm('network').toLogger();
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
if ( builtinDirectives.length !== 0 ) {
|
|
992
|
+
cspSubsets[0] = builtinDirectives.join(', ');
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
// ======== filter-based policies
|
|
996
|
+
|
|
997
|
+
// Static filtering.
|
|
998
|
+
|
|
999
|
+
fctxt.type = requestType;
|
|
1000
|
+
const staticDirectives =
|
|
1001
|
+
staticNetFilteringEngine.matchAndFetchModifiers(fctxt, 'csp');
|
|
1002
|
+
if ( staticDirectives !== undefined ) {
|
|
1003
|
+
for ( const directive of staticDirectives ) {
|
|
1004
|
+
if ( directive.result !== 1 ) { continue; }
|
|
1005
|
+
cspSubsets.push(directive.value);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// URL filtering `allow` rules override static filtering.
|
|
1010
|
+
if (
|
|
1011
|
+
cspSubsets.length !== 0 &&
|
|
1012
|
+
sessionURLFiltering.evaluateZ(
|
|
1013
|
+
fctxt.getTabHostname(),
|
|
1014
|
+
fctxt.url,
|
|
1015
|
+
'csp'
|
|
1016
|
+
) === 2
|
|
1017
|
+
) {
|
|
1018
|
+
if ( logger.enabled ) {
|
|
1019
|
+
fctxt.setRealm('network')
|
|
1020
|
+
.setType('csp')
|
|
1021
|
+
.setFilter(sessionURLFiltering.toLogData())
|
|
1022
|
+
.toLogger();
|
|
1023
|
+
}
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// Dynamic filtering `allow` rules override static filtering.
|
|
1028
|
+
if (
|
|
1029
|
+
cspSubsets.length !== 0 &&
|
|
1030
|
+
µb.userSettings.advancedUserEnabled &&
|
|
1031
|
+
sessionFirewall.evaluateCellZY(
|
|
1032
|
+
fctxt.getTabHostname(),
|
|
1033
|
+
fctxt.getTabHostname(),
|
|
1034
|
+
'*'
|
|
1035
|
+
) === 2
|
|
1036
|
+
) {
|
|
1037
|
+
if ( logger.enabled ) {
|
|
1038
|
+
fctxt.setRealm('network')
|
|
1039
|
+
.setType('csp')
|
|
1040
|
+
.setFilter(sessionFirewall.toLogData())
|
|
1041
|
+
.toLogger();
|
|
1042
|
+
}
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
// <<<<<<<< All policies have been collected
|
|
1047
|
+
|
|
1048
|
+
// Static CSP policies will be applied.
|
|
1049
|
+
|
|
1050
|
+
if ( logger.enabled && staticDirectives !== undefined ) {
|
|
1051
|
+
fctxt.setRealm('network')
|
|
1052
|
+
.pushFilters(staticDirectives.map(a => a.logData()))
|
|
1053
|
+
.toLogger();
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
if ( cspSubsets.length === 0 ) { return; }
|
|
1057
|
+
|
|
1058
|
+
µb.updateToolbarIcon(fctxt.tabId, 0b0010);
|
|
1059
|
+
|
|
1060
|
+
// Use comma to merge CSP directives.
|
|
1061
|
+
// Ref.: https://www.w3.org/TR/CSP2/#implementation-considerations
|
|
1062
|
+
//
|
|
1063
|
+
// https://github.com/gorhill/uMatrix/issues/967
|
|
1064
|
+
// Inject a new CSP header rather than modify an existing one, except
|
|
1065
|
+
// if the current environment does not support merging headers:
|
|
1066
|
+
// Firefox 58/webext and less can't merge CSP headers, so we will merge
|
|
1067
|
+
// them here.
|
|
1068
|
+
|
|
1069
|
+
responseHeaders.push({
|
|
1070
|
+
name: 'Content-Security-Policy',
|
|
1071
|
+
value: cspSubsets.join(', ')
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
return true;
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
/******************************************************************************/
|
|
1078
|
+
|
|
1079
|
+
const injectPP = function(fctxt, pageStore, responseHeaders) {
|
|
1080
|
+
const permissions = [];
|
|
1081
|
+
const directives = staticNetFilteringEngine.matchAndFetchModifiers(fctxt, 'permissions');
|
|
1082
|
+
if ( directives !== undefined ) {
|
|
1083
|
+
for ( const directive of directives ) {
|
|
1084
|
+
if ( directive.result !== 1 ) { continue; }
|
|
1085
|
+
permissions.push(directive.value.replace('|', ', '));
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
if ( logger.enabled && directives !== undefined ) {
|
|
1090
|
+
fctxt.setRealm('network')
|
|
1091
|
+
.pushFilters(directives.map(a => a.logData()))
|
|
1092
|
+
.toLogger();
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
if ( permissions.length === 0 ) { return; }
|
|
1096
|
+
|
|
1097
|
+
µb.updateToolbarIcon(fctxt.tabId, 0x02);
|
|
1098
|
+
|
|
1099
|
+
responseHeaders.push({
|
|
1100
|
+
name: 'permissions-policy',
|
|
1101
|
+
value: permissions.join(', ')
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
return true;
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
/******************************************************************************/
|
|
1108
|
+
|
|
1109
|
+
// https://github.com/gorhill/uBlock/issues/1163
|
|
1110
|
+
// "Block elements by size".
|
|
1111
|
+
// https://github.com/gorhill/uBlock/issues/1390#issuecomment-187310719
|
|
1112
|
+
// Do not foil when the media element is fetched from the browser
|
|
1113
|
+
// cache. This works only when the webext API supports the `fromCache`
|
|
1114
|
+
// property (Firefox).
|
|
1115
|
+
|
|
1116
|
+
const foilLargeMediaElement = function(details, fctxt, pageStore) {
|
|
1117
|
+
if ( details.fromCache === true ) { return; }
|
|
1118
|
+
|
|
1119
|
+
let size = 0;
|
|
1120
|
+
if ( µb.userSettings.largeMediaSize !== 0 ) {
|
|
1121
|
+
const headers = details.responseHeaders;
|
|
1122
|
+
const i = headerIndexFromName('content-length', headers);
|
|
1123
|
+
if ( i === -1 ) { return; }
|
|
1124
|
+
size = parseInt(headers[i].value, 10) || 0;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
const result = pageStore.filterLargeMediaElement(fctxt, size);
|
|
1128
|
+
if ( result === 0 ) { return; }
|
|
1129
|
+
|
|
1130
|
+
if ( logger.enabled ) {
|
|
1131
|
+
fctxt.setRealm('network').toLogger();
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
return { cancel: true };
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1137
|
+
/******************************************************************************/
|
|
1138
|
+
|
|
1139
|
+
// Caller must ensure headerName is normalized to lower case.
|
|
1140
|
+
|
|
1141
|
+
const headerIndexFromName = function(headerName, headers) {
|
|
1142
|
+
let i = headers.length;
|
|
1143
|
+
while ( i-- ) {
|
|
1144
|
+
if ( headers[i].name.toLowerCase() === headerName ) {
|
|
1145
|
+
return i;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
return -1;
|
|
1149
|
+
};
|
|
1150
|
+
|
|
1151
|
+
const headerValueFromName = function(headerName, headers) {
|
|
1152
|
+
const i = headerIndexFromName(headerName, headers);
|
|
1153
|
+
return i !== -1 ? headers[i].value : '';
|
|
1154
|
+
};
|
|
1155
|
+
|
|
1156
|
+
/******************************************************************************/
|
|
1157
|
+
|
|
1158
|
+
const strictBlockBypasser = {
|
|
1159
|
+
hostnameToDeadlineMap: new Map(),
|
|
1160
|
+
cleanupTimer: vAPI.defer.create(( ) => {
|
|
1161
|
+
strictBlockBypasser.cleanup();
|
|
1162
|
+
}),
|
|
1163
|
+
|
|
1164
|
+
cleanup: function() {
|
|
1165
|
+
for ( const [ hostname, deadline ] of this.hostnameToDeadlineMap ) {
|
|
1166
|
+
if ( deadline <= Date.now() ) {
|
|
1167
|
+
this.hostnameToDeadlineMap.delete(hostname);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
},
|
|
1171
|
+
|
|
1172
|
+
revokeTime: function() {
|
|
1173
|
+
return Date.now() + µb.hiddenSettings.strictBlockingBypassDuration * 1000;
|
|
1174
|
+
},
|
|
1175
|
+
|
|
1176
|
+
bypass: function(hostname) {
|
|
1177
|
+
if ( typeof hostname !== 'string' || hostname === '' ) { return; }
|
|
1178
|
+
this.hostnameToDeadlineMap.set(hostname, this.revokeTime());
|
|
1179
|
+
},
|
|
1180
|
+
|
|
1181
|
+
isBypassed: function(hostname) {
|
|
1182
|
+
if ( this.hostnameToDeadlineMap.size === 0 ) { return false; }
|
|
1183
|
+
this.cleanupTimer.on({ sec: µb.hiddenSettings.strictBlockingBypassDuration + 10 });
|
|
1184
|
+
for (;;) {
|
|
1185
|
+
const deadline = this.hostnameToDeadlineMap.get(hostname);
|
|
1186
|
+
if ( deadline !== undefined ) {
|
|
1187
|
+
if ( deadline > Date.now() ) {
|
|
1188
|
+
this.hostnameToDeadlineMap.set(hostname, this.revokeTime());
|
|
1189
|
+
return true;
|
|
1190
|
+
}
|
|
1191
|
+
this.hostnameToDeadlineMap.delete(hostname);
|
|
1192
|
+
}
|
|
1193
|
+
const pos = hostname.indexOf('.');
|
|
1194
|
+
if ( pos === -1 ) { break; }
|
|
1195
|
+
hostname = hostname.slice(pos + 1);
|
|
1196
|
+
}
|
|
1197
|
+
return false;
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
|
|
1201
|
+
/******************************************************************************/
|
|
1202
|
+
|
|
1203
|
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/2350
|
|
1204
|
+
// Added scriptlet injection attempt at onResponseStarted time as per
|
|
1205
|
+
// https://github.com/AdguardTeam/AdguardBrowserExtension/issues/1029 and
|
|
1206
|
+
// https://github.com/AdguardTeam/AdguardBrowserExtension/blob/9ab85be5/Extension/src/background/webrequest.js#L620
|
|
1207
|
+
|
|
1208
|
+
const webRequest = {
|
|
1209
|
+
onBeforeRequest,
|
|
1210
|
+
|
|
1211
|
+
start: (( ) => {
|
|
1212
|
+
vAPI.net = new vAPI.Net();
|
|
1213
|
+
if ( vAPI.Net.canSuspend() ) {
|
|
1214
|
+
vAPI.net.suspend();
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
return ( ) => {
|
|
1218
|
+
vAPI.net.setSuspendableListener(onBeforeRequest);
|
|
1219
|
+
vAPI.net.addListener(
|
|
1220
|
+
'onHeadersReceived',
|
|
1221
|
+
onHeadersReceived,
|
|
1222
|
+
{ urls: [ 'http://*/*', 'https://*/*' ] },
|
|
1223
|
+
[ 'blocking', 'responseHeaders' ]
|
|
1224
|
+
);
|
|
1225
|
+
vAPI.net.addListener(
|
|
1226
|
+
'onResponseStarted',
|
|
1227
|
+
details => {
|
|
1228
|
+
if ( details.tabId === -1 ) { return; }
|
|
1229
|
+
const pageStore = µb.pageStoreFromTabId(details.tabId);
|
|
1230
|
+
if ( pageStore === null ) { return; }
|
|
1231
|
+
if ( pageStore.getNetFilteringSwitch() === false ) { return; }
|
|
1232
|
+
scriptletFilteringEngine.injectNow(details);
|
|
1233
|
+
},
|
|
1234
|
+
{
|
|
1235
|
+
types: [ 'main_frame', 'sub_frame' ],
|
|
1236
|
+
urls: [ 'http://*/*', 'https://*/*' ]
|
|
1237
|
+
}
|
|
1238
|
+
);
|
|
1239
|
+
vAPI.defer.once({ sec: µb.hiddenSettings.toolbarWarningTimeout }).then(( ) => {
|
|
1240
|
+
if ( vAPI.net.hasUnprocessedRequest() === false ) { return; }
|
|
1241
|
+
vAPI.net.removeUnprocessedRequest();
|
|
1242
|
+
return vAPI.tabs.getCurrent();
|
|
1243
|
+
}).then(tab => {
|
|
1244
|
+
if ( tab instanceof Object === false ) { return; }
|
|
1245
|
+
µb.updateToolbarIcon(tab.id, 0b0110);
|
|
1246
|
+
});
|
|
1247
|
+
vAPI.net.unsuspend({ all: true });
|
|
1248
|
+
};
|
|
1249
|
+
})(),
|
|
1250
|
+
|
|
1251
|
+
strictBlockBypass: hostname => {
|
|
1252
|
+
strictBlockBypasser.bypass(hostname);
|
|
1253
|
+
},
|
|
1254
|
+
};
|
|
1255
|
+
|
|
1256
|
+
/******************************************************************************/
|
|
1257
|
+
|
|
1258
|
+
export default webRequest;
|
|
1259
|
+
|
|
1260
|
+
/******************************************************************************/
|