From 41ca36a48e6c4394f19bd7c794d0c0893929a5c8 Mon Sep 17 00:00:00 2001 From: Gildas Date: Thu, 17 Feb 2022 02:28:16 +0100 Subject: [PATCH] refactor folders structure --- .eslintrc.js | 2 +- build-extension.sh | 32 +++---- cli/back-ends/common/scripts.js | 12 +-- dist/extension-background.js | 1 - dist/extension-core.js | 1 - dist/infobar.js | 1 - dist/single-file-bootstrap.js | 1 - dist/single-file-frames.js | 1 - dist/single-file.js | 1 - extension/core/bg/background.html | 16 ---- extension/lib/woleet/woleet.js | 56 ------------- extension/ui/pages/editor.html | 78 ------------------ {dist => lib}/chrome-browser-polyfill.js | 0 lib/extension-background.js | 1 + {dist => lib}/extension-bootstrap.js | 0 lib/extension-core.js | 1 + {dist => lib}/extension-frames.js | 0 {dist => lib}/extension.js | 0 lib/infobar.js | 1 + {dist => lib}/single-file-background.js | 0 lib/single-file-bootstrap.js | 1 + lib/single-file-frames.js | 1 + lib/single-file.js | 1 + {dist => lib}/web/editor/editor-helper-web.js | 0 {dist => lib}/web/editor/editor-init-web.js | 0 {dist => lib}/web/editor/editor-web.js | 2 +- {dist => lib}/web/hooks/hooks-frames-web.js | 0 {dist => lib}/web/hooks/hooks-web.js | 0 {dist => lib}/web/infobar-web.js | 0 manifest.json | 64 +++++++------- rollup.config.dev.js | 68 +++++++-------- rollup.config.js | 68 +++++++-------- .../common}/ui/content/content-infobar-web.js | 0 .../common}/ui/content/content-infobar.js | 2 +- .../extension}/core/bg/autosave-util.js | 0 .../extension}/core/bg/autosave.js | 0 src/extension/core/bg/background.html | 16 ++++ .../extension}/core/bg/bookmarks.js | 0 .../extension}/core/bg/bootstrap.js | 0 .../extension}/core/bg/business.js | 4 +- .../extension}/core/bg/companion.js | 0 .../extension}/core/bg/config.js | 0 .../extension}/core/bg/devtools.js | 0 .../extension}/core/bg/download-util.js | 0 .../extension}/core/bg/downloads.js | 0 .../extension}/core/bg/editor.js | 2 +- {extension => src/extension}/core/bg/index.js | 0 .../extension}/core/bg/requests.js | 0 .../extension}/core/bg/tabs-data.js | 0 .../extension}/core/bg/tabs-util.js | 0 {extension => src/extension}/core/bg/tabs.js | 0 .../extension}/core/common/download.js | 0 .../core/content/content-bootstrap.js | 0 .../extension}/core/content/content-frames.js | 0 .../extension}/core/content/content.js | 0 .../extension}/core/devtools/devtools.html | 2 +- .../extension}/core/devtools/devtools.js | 0 {extension => src/extension}/index.js | 0 .../extension}/lib/gdrive/gdrive.js | 0 .../extension}/lib/github/github.js | 0 .../lib/readability/Readability-readerable.js | 0 .../extension}/lib/readability/Readability.js | 0 .../extension}/lib/single-file/background.js | 0 .../chrome-browser-polyfill.js | 0 .../lib/single-file/core/bg/scripts.js | 8 +- .../lib/single-file/fetch/bg/fetch.js | 0 .../fetch/content/content-fetch.js | 0 .../single-file/frame-tree/bg/frame-tree.js | 0 .../lib/single-file/lazy/bg/lazy-timeout.js | 0 {extension => src/extension}/ui/bg/index.js | 0 .../extension}/ui/bg/ui-button.js | 4 +- .../extension}/ui/bg/ui-commands.js | 0 .../extension}/ui/bg/ui-editor.js | 12 +-- .../extension}/ui/bg/ui-menus.js | 2 +- .../extension}/ui/bg/ui-options.js | 2 +- .../extension}/ui/bg/ui-panel.js | 0 .../extension}/ui/bg/ui-pendings.js | 0 .../extension}/ui/common/content-error.js | 0 .../content/content-ui-editor-helper-web.js | 2 +- .../ui/content/content-ui-editor-init-web.js | 0 .../ui/content/content-ui-editor-web.js | 2 +- .../extension}/ui/content/content-ui.js | 0 .../extension}/ui/pages/editor-frame-web.css | 0 .../extension}/ui/pages/editor-mask-web.css | 0 .../extension}/ui/pages/editor-note-web.css | 0 .../extension}/ui/pages/editor.css | 0 src/extension/ui/pages/editor.html | 78 ++++++++++++++++++ .../extension}/ui/pages/help.css | 0 .../extension}/ui/pages/help.html | 0 .../extension}/ui/pages/options.css | 0 .../extension}/ui/pages/options.html | 2 +- .../extension}/ui/pages/panel.css | 0 .../extension}/ui/pages/panel.html | 0 .../extension}/ui/pages/pendings.css | 0 .../extension}/ui/pages/pendings.html | 2 +- .../ui/resources/button_cut_inner.png | Bin .../ui/resources/button_cut_outer.png | Bin .../extension}/ui/resources/button_delete.png | Bin .../ui/resources/button_delete_all.png | Bin .../ui/resources/button_download.png | Bin .../extension}/ui/resources/button_edit.png | Bin .../ui/resources/button_highlighter_blue.png | Bin .../resources/button_highlighter_delete.png | Bin .../ui/resources/button_highlighter_green.png | Bin .../resources/button_highlighter_hidden.png | Bin .../ui/resources/button_highlighter_pink.png | Bin .../resources/button_highlighter_visible.png | Bin .../resources/button_highlighter_yellow.png | Bin .../extension}/ui/resources/button_new.png | Bin .../ui/resources/button_note_blue.png | Bin .../ui/resources/button_note_edit.png | Bin .../ui/resources/button_note_format.png | Bin .../ui/resources/button_note_green.png | Bin .../ui/resources/button_note_hidden.png | Bin .../ui/resources/button_note_pink.png | Bin .../ui/resources/button_note_visible.png | Bin .../ui/resources/button_note_yellow.png | Bin .../extension}/ui/resources/button_ok.png | Bin .../extension}/ui/resources/button_print.png | Bin .../ui/resources/button_redo_cut.png | Bin .../ui/resources/button_undo_all_cut.png | Bin .../ui/resources/button_undo_cut.png | Bin .../extension}/ui/resources/icon_128.png | Bin .../ui/resources/icon_128_wait0.png | Bin .../ui/resources/icon_128_wait1.png | Bin .../ui/resources/icon_128_wait2.png | Bin .../ui/resources/icon_128_wait3.png | Bin .../ui/resources/icon_128_wait4.png | Bin .../ui/resources/icon_128_wait5.png | Bin .../ui/resources/icon_128_wait6.png | Bin .../ui/resources/icon_128_wait7.png | Bin .../ui/resources/icon_128_wait8.png | Bin .../extension}/ui/resources/icon_16.png | Bin .../extension}/ui/resources/icon_48.png | Bin .../extension}/ui/resources/icon_64.png | Bin {lib => src}/single-file/index.js | 0 .../modules/css-fonts-alt-minifier.js | 0 .../single-file/modules/css-fonts-minifier.js | 0 .../single-file/modules/css-matched-rules.js | 0 .../modules/css-medias-alt-minifier.js | 0 .../single-file/modules/css-rules-minifier.js | 0 .../modules/html-images-alt-minifier.js | 0 .../single-file/modules/html-minifier.js | 0 .../single-file/modules/html-serializer.js | 0 {lib => src}/single-file/modules/index.js | 0 .../frame-tree/content/content-frame-tree.js | 0 .../hooks/content/content-hooks-frames-web.js | 0 .../hooks/content/content-hooks-frames.js | 2 +- .../hooks/content/content-hooks-web.js | 0 .../processors/hooks/content/content-hooks.js | 2 +- {lib => src}/single-file/processors/index.js | 0 .../lazy/content/content-lazy-loader.js | 0 .../single-file/single-file-bootstrap.js | 0 {lib => src}/single-file/single-file-core.js | 0 .../single-file/single-file-frames.js | 0 .../single-file/single-file-helper.js | 0 {lib => src}/single-file/single-file-util.js | 0 .../vendor/css-font-property-parser.js | 0 .../vendor/css-media-query-parser.js | 0 .../single-file/vendor/css-minifier.js | 0 {lib => src}/single-file/vendor/css-tree.js | 0 .../single-file/vendor/css-unescape.js | 0 .../single-file/vendor/html-srcset-parser.js | 0 {lib => src}/single-file/vendor/index.js | 0 .../single-file/vendor/mime-type-parser.js | 0 165 files changed, 249 insertions(+), 305 deletions(-) delete mode 100644 dist/extension-background.js delete mode 100644 dist/extension-core.js delete mode 100644 dist/infobar.js delete mode 100644 dist/single-file-bootstrap.js delete mode 100644 dist/single-file-frames.js delete mode 100644 dist/single-file.js delete mode 100644 extension/core/bg/background.html delete mode 100644 extension/lib/woleet/woleet.js delete mode 100644 extension/ui/pages/editor.html rename {dist => lib}/chrome-browser-polyfill.js (100%) create mode 100644 lib/extension-background.js rename {dist => lib}/extension-bootstrap.js (100%) create mode 100644 lib/extension-core.js rename {dist => lib}/extension-frames.js (100%) rename {dist => lib}/extension.js (100%) create mode 100644 lib/infobar.js rename {dist => lib}/single-file-background.js (100%) create mode 100644 lib/single-file-bootstrap.js create mode 100644 lib/single-file-frames.js create mode 100644 lib/single-file.js rename {dist => lib}/web/editor/editor-helper-web.js (100%) rename {dist => lib}/web/editor/editor-init-web.js (100%) rename {dist => lib}/web/editor/editor-web.js (99%) rename {dist => lib}/web/hooks/hooks-frames-web.js (100%) rename {dist => lib}/web/hooks/hooks-web.js (100%) rename {dist => lib}/web/infobar-web.js (100%) rename {common => src/common}/ui/content/content-infobar-web.js (100%) rename {common => src/common}/ui/content/content-infobar.js (97%) rename {extension => src/extension}/core/bg/autosave-util.js (100%) rename {extension => src/extension}/core/bg/autosave.js (100%) create mode 100644 src/extension/core/bg/background.html rename {extension => src/extension}/core/bg/bookmarks.js (100%) rename {extension => src/extension}/core/bg/bootstrap.js (100%) rename {extension => src/extension}/core/bg/business.js (99%) rename {extension => src/extension}/core/bg/companion.js (100%) rename {extension => src/extension}/core/bg/config.js (100%) rename {extension => src/extension}/core/bg/devtools.js (100%) rename {extension => src/extension}/core/bg/download-util.js (100%) rename {extension => src/extension}/core/bg/downloads.js (100%) rename {extension => src/extension}/core/bg/editor.js (98%) rename {extension => src/extension}/core/bg/index.js (100%) rename {extension => src/extension}/core/bg/requests.js (100%) rename {extension => src/extension}/core/bg/tabs-data.js (100%) rename {extension => src/extension}/core/bg/tabs-util.js (100%) rename {extension => src/extension}/core/bg/tabs.js (100%) rename {extension => src/extension}/core/common/download.js (100%) rename {extension => src/extension}/core/content/content-bootstrap.js (100%) rename {extension => src/extension}/core/content/content-frames.js (100%) rename {extension => src/extension}/core/content/content.js (100%) rename {extension => src/extension}/core/devtools/devtools.html (67%) rename {extension => src/extension}/core/devtools/devtools.js (100%) rename {extension => src/extension}/index.js (100%) rename {extension => src/extension}/lib/gdrive/gdrive.js (100%) rename {extension => src/extension}/lib/github/github.js (100%) rename {extension => src/extension}/lib/readability/Readability-readerable.js (100%) rename {extension => src/extension}/lib/readability/Readability.js (100%) rename {extension => src/extension}/lib/single-file/background.js (100%) rename {extension => src/extension}/lib/single-file/browser-polyfill/chrome-browser-polyfill.js (100%) rename {extension => src/extension}/lib/single-file/core/bg/scripts.js (95%) rename {extension => src/extension}/lib/single-file/fetch/bg/fetch.js (100%) rename {extension => src/extension}/lib/single-file/fetch/content/content-fetch.js (100%) rename {extension => src/extension}/lib/single-file/frame-tree/bg/frame-tree.js (100%) rename {extension => src/extension}/lib/single-file/lazy/bg/lazy-timeout.js (100%) rename {extension => src/extension}/ui/bg/index.js (100%) rename {extension => src/extension}/ui/bg/ui-button.js (98%) rename {extension => src/extension}/ui/bg/ui-commands.js (100%) rename {extension => src/extension}/ui/bg/ui-editor.js (96%) rename {extension => src/extension}/ui/bg/ui-menus.js (99%) rename {extension => src/extension}/ui/bg/ui-options.js (99%) rename {extension => src/extension}/ui/bg/ui-panel.js (100%) rename {extension => src/extension}/ui/bg/ui-pendings.js (100%) rename {extension => src/extension}/ui/common/content-error.js (100%) rename {extension => src/extension}/ui/content/content-ui-editor-helper-web.js (93%) rename {extension => src/extension}/ui/content/content-ui-editor-init-web.js (100%) rename {extension => src/extension}/ui/content/content-ui-editor-web.js (99%) rename {extension => src/extension}/ui/content/content-ui.js (100%) rename {extension => src/extension}/ui/pages/editor-frame-web.css (100%) rename {extension => src/extension}/ui/pages/editor-mask-web.css (100%) rename {extension => src/extension}/ui/pages/editor-note-web.css (100%) rename {extension => src/extension}/ui/pages/editor.css (100%) create mode 100644 src/extension/ui/pages/editor.html rename {extension => src/extension}/ui/pages/help.css (100%) rename {extension => src/extension}/ui/pages/help.html (100%) rename {extension => src/extension}/ui/pages/options.css (100%) rename {extension => src/extension}/ui/pages/options.html (99%) rename {extension => src/extension}/ui/pages/panel.css (100%) rename {extension => src/extension}/ui/pages/panel.html (100%) rename {extension => src/extension}/ui/pages/pendings.css (100%) rename {extension => src/extension}/ui/pages/pendings.html (95%) rename {extension => src/extension}/ui/resources/button_cut_inner.png (100%) rename {extension => src/extension}/ui/resources/button_cut_outer.png (100%) rename {extension => src/extension}/ui/resources/button_delete.png (100%) rename {extension => src/extension}/ui/resources/button_delete_all.png (100%) rename {extension => src/extension}/ui/resources/button_download.png (100%) rename {extension => src/extension}/ui/resources/button_edit.png (100%) rename {extension => src/extension}/ui/resources/button_highlighter_blue.png (100%) rename {extension => src/extension}/ui/resources/button_highlighter_delete.png (100%) rename {extension => src/extension}/ui/resources/button_highlighter_green.png (100%) rename {extension => src/extension}/ui/resources/button_highlighter_hidden.png (100%) rename {extension => src/extension}/ui/resources/button_highlighter_pink.png (100%) rename {extension => src/extension}/ui/resources/button_highlighter_visible.png (100%) rename {extension => src/extension}/ui/resources/button_highlighter_yellow.png (100%) rename {extension => src/extension}/ui/resources/button_new.png (100%) rename {extension => src/extension}/ui/resources/button_note_blue.png (100%) rename {extension => src/extension}/ui/resources/button_note_edit.png (100%) rename {extension => src/extension}/ui/resources/button_note_format.png (100%) rename {extension => src/extension}/ui/resources/button_note_green.png (100%) rename {extension => src/extension}/ui/resources/button_note_hidden.png (100%) rename {extension => src/extension}/ui/resources/button_note_pink.png (100%) rename {extension => src/extension}/ui/resources/button_note_visible.png (100%) rename {extension => src/extension}/ui/resources/button_note_yellow.png (100%) rename {extension => src/extension}/ui/resources/button_ok.png (100%) rename {extension => src/extension}/ui/resources/button_print.png (100%) rename {extension => src/extension}/ui/resources/button_redo_cut.png (100%) rename {extension => src/extension}/ui/resources/button_undo_all_cut.png (100%) rename {extension => src/extension}/ui/resources/button_undo_cut.png (100%) rename {extension => src/extension}/ui/resources/icon_128.png (100%) rename {extension => src/extension}/ui/resources/icon_128_wait0.png (100%) rename {extension => src/extension}/ui/resources/icon_128_wait1.png (100%) rename {extension => src/extension}/ui/resources/icon_128_wait2.png (100%) rename {extension => src/extension}/ui/resources/icon_128_wait3.png (100%) rename {extension => src/extension}/ui/resources/icon_128_wait4.png (100%) rename {extension => src/extension}/ui/resources/icon_128_wait5.png (100%) rename {extension => src/extension}/ui/resources/icon_128_wait6.png (100%) rename {extension => src/extension}/ui/resources/icon_128_wait7.png (100%) rename {extension => src/extension}/ui/resources/icon_128_wait8.png (100%) rename {extension => src/extension}/ui/resources/icon_16.png (100%) rename {extension => src/extension}/ui/resources/icon_48.png (100%) rename {extension => src/extension}/ui/resources/icon_64.png (100%) rename {lib => src}/single-file/index.js (100%) rename {lib => src}/single-file/modules/css-fonts-alt-minifier.js (100%) rename {lib => src}/single-file/modules/css-fonts-minifier.js (100%) rename {lib => src}/single-file/modules/css-matched-rules.js (100%) rename {lib => src}/single-file/modules/css-medias-alt-minifier.js (100%) rename {lib => src}/single-file/modules/css-rules-minifier.js (100%) rename {lib => src}/single-file/modules/html-images-alt-minifier.js (100%) rename {lib => src}/single-file/modules/html-minifier.js (100%) rename {lib => src}/single-file/modules/html-serializer.js (100%) rename {lib => src}/single-file/modules/index.js (100%) rename {lib => src}/single-file/processors/frame-tree/content/content-frame-tree.js (100%) rename {lib => src}/single-file/processors/hooks/content/content-hooks-frames-web.js (100%) rename {lib => src}/single-file/processors/hooks/content/content-hooks-frames.js (98%) rename {lib => src}/single-file/processors/hooks/content/content-hooks-web.js (100%) rename {lib => src}/single-file/processors/hooks/content/content-hooks.js (94%) rename {lib => src}/single-file/processors/index.js (100%) rename {lib => src}/single-file/processors/lazy/content/content-lazy-loader.js (100%) rename {lib => src}/single-file/single-file-bootstrap.js (100%) rename {lib => src}/single-file/single-file-core.js (100%) rename {lib => src}/single-file/single-file-frames.js (100%) rename {lib => src}/single-file/single-file-helper.js (100%) rename {lib => src}/single-file/single-file-util.js (100%) rename {lib => src}/single-file/vendor/css-font-property-parser.js (100%) rename {lib => src}/single-file/vendor/css-media-query-parser.js (100%) rename {lib => src}/single-file/vendor/css-minifier.js (100%) rename {lib => src}/single-file/vendor/css-tree.js (100%) rename {lib => src}/single-file/vendor/css-unescape.js (100%) rename {lib => src}/single-file/vendor/html-srcset-parser.js (100%) rename {lib => src}/single-file/vendor/index.js (100%) rename {lib => src}/single-file/vendor/mime-type-parser.js (100%) diff --git a/.eslintrc.js b/.eslintrc.js index 700aa239d..07a73e38c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,7 +15,7 @@ module.exports = { "sourceType": "module" }, "ignorePatterns": [ - "dist/" + "/lib/" ], "rules": { "indent": [ diff --git a/build-extension.sh b/build-extension.sh index 532ea587a..824df97ac 100644 --- a/build-extension.sh +++ b/build-extension.sh @@ -1,40 +1,40 @@ #!/bin/sh npx rollup -c rollup.config.js -zip -r singlefile-extension-source.zip manifest.json package.json _locales extension common lib rollup*.js .eslintrc.js build-extension.sh +zip -r singlefile-extension-source.zip manifest.json package.json _locales src rollup*.js .eslintrc.js build-extension.sh rm singlefile-extension-firefox.zip singlefile-extension-chromium.zip singlefile-extension-edge.zip cp manifest.json manifest.copy.json -cp extension/core/bg/downloads.js downloads.copy.js -sed -i 's/207618107333-3pj2pmelhnl4sf3rpctghs9cean3q8nj/207618107333-7tjs1im1pighftpoepea2kvkubnfjj44/g' extension/core/bg/downloads.js +cp src/extension/core/bg/downloads.js downloads.copy.js +sed -i 's/207618107333-3pj2pmelhnl4sf3rpctghs9cean3q8nj/207618107333-7tjs1im1pighftpoepea2kvkubnfjj44/g' src/extension/core/bg/downloads.js -cp extension/core/bg/config.js config.copy.js -cp extension/core/bg/companion.js companion.copy.js +cp src/extension/core/bg/config.js config.copy.js +cp src/extension/core/bg/companion.js companion.copy.js jq "del(.options_page,.background.persistent,.optional_permissions[0],.permissions[3],.oauth2)" manifest.copy.json > manifest.json sed -i 's/207618107333-3pj2pmelhnl4sf3rpctghs9cean3q8nj/207618107333-7tjs1im1pighftpoepea2kvkubnfjj44/g' manifest.json -sed -i 's/forceWebAuthFlow: false/forceWebAuthFlow: true/g' extension/core/bg/config.js -sed -i 's/enabled: true/enabled: false/g' extension/core/bg/companion.js -zip -r singlefile-extension-firefox.zip manifest.json dist _locales extension -mv config.copy.js extension/core/bg/config.js -mv companion.copy.js extension/core/bg/companion.js +sed -i 's/forceWebAuthFlow: false/forceWebAuthFlow: true/g' src/extension/core/bg/config.js +sed -i 's/enabled: true/enabled: false/g' src/extension/core/bg/companion.js +zip -r singlefile-extension-firefox.zip manifest.json lib _locales src/extension +mv config.copy.js src/extension/core/bg/config.js +mv companion.copy.js src/extension/core/bg/companion.js jq "del(.browser_specific_settings,.permissions[0],.permissions[1],.options_ui.browser_style)" manifest.copy.json > manifest.json sed -i 's/207618107333-3pj2pmelhnl4sf3rpctghs9cean3q8nj/207618107333-7tjs1im1pighftpoepea2kvkubnfjj44/g' manifest.json -zip -r singlefile-extension-chromium.zip manifest.json dist _locales extension +zip -r singlefile-extension-chromium.zip manifest.json lib _locales src/extension -cp extension/core/bg/config.js config.copy.js +cp src/extension/core/bg/config.js config.copy.js jq "del(.browser_specific_settings,.permissions[0],.permissions[1],.options_ui.browser_style)" manifest.copy.json > manifest.json sed -i 's/207618107333-3pj2pmelhnl4sf3rpctghs9cean3q8nj/207618107333-7tjs1im1pighftpoepea2kvkubnfjj44/g' manifest.json -sed -i 's/forceWebAuthFlow: false/forceWebAuthFlow: true/g' extension/core/bg/config.js +sed -i 's/forceWebAuthFlow: false/forceWebAuthFlow: true/g' src/extension/core/bg/config.js mkdir _locales.copy cp -R _locales/* _locales.copy rm -rf _locales/* cp -R _locales.copy/en _locales -zip -r singlefile-extension-edge.zip manifest.json dist _locales extension +zip -r singlefile-extension-edge.zip manifest.json lib _locales src/extension rm -rf _locales/* mv _locales.copy/* _locales rmdir _locales.copy -mv config.copy.js extension/core/bg/config.js +mv config.copy.js src/extension/core/bg/config.js mv manifest.copy.json manifest.json -mv downloads.copy.js extension/core/bg/downloads.js \ No newline at end of file +mv downloads.copy.js src/extension/core/bg/downloads.js \ No newline at end of file diff --git a/cli/back-ends/common/scripts.js b/cli/back-ends/common/scripts.js index 4c31634d8..91a57855e 100644 --- a/cli/back-ends/common/scripts.js +++ b/cli/back-ends/common/scripts.js @@ -26,18 +26,18 @@ const fs = require("fs"); const SCRIPTS = [ - "dist/infobar.js" + "lib/infobar.js" ]; const INDEX_SCRIPTS = [ - "dist/single-file.js", - "dist/single-file-bootstrap.js" + "lib/single-file.js", + "lib/single-file-bootstrap.js" ]; const WEB_SCRIPTS = [ - "/dist/web/hooks/hooks-web.js", - "/dist/web/hooks/hooks-frames-web.js", - "/dist/web/infobar-web.js" + "/lib/web/hooks/hooks-web.js", + "/lib/web/hooks/hooks-frames-web.js", + "/lib/web/infobar-web.js" ]; exports.get = async options => { diff --git a/dist/extension-background.js b/dist/extension-background.js deleted file mode 100644 index 05651f494..000000000 --- a/dist/extension-background.js +++ /dev/null @@ -1 +0,0 @@ -!function(){"use strict";async function e(t,a){let n;try{n=await browser.downloads.download(t)}catch(n){if(n.message){const r=n.message.toLowerCase(),o=r.includes("illegal characters")||r.includes("invalid filename");if(o&&t.filename.startsWith("."))return t.filename=a+t.filename,e(t,a);if(o&&t.filename.includes(","))return t.filename=t.filename.replace(/,/g,a),e(t,a);if(o&&!t.filename.match(/^[\x00-\x7F]+$/))return t.filename=t.filename.replace(/[^\x00-\x7F]+/g,a),e(t,a);if((r.includes("'incognito'")||r.includes('"incognito"'))&&t.incognito)return delete t.incognito,e(t,a);if("conflictaction prompt not yet implemented"==r&&t.conflictAction)return delete t.conflictAction,e(t,a);if(r.includes("canceled"))return{};throw n}throw n}return new Promise(((e,t)=>{browser.downloads.onChanged.addListener((function a(r){r.id==n&&r.state&&("complete"==r.state.current&&(browser.downloads.search({id:n}).then((t=>e({filename:t[0]&&t[0].filename}))).catch((()=>e({}))),browser.downloads.onChanged.removeListener(a)),"interrupted"==r.state.current&&(r.error&&"USER_CANCELED"==r.error.current?e({}):t(new Error(r.state.current)),browser.downloads.onChanged.removeListener(a)))}))}))}let t,a,n;async function r(e){a&&delete a[e];const t=await s();if(t[e]){const a=t[e].autoSave;t[e]={autoSave:a},await i(t)}}function o(e){return a||(a={}),void 0===e||a[e]||(a[e]={}),a}async function s(e){if(!t){const e=await browser.storage.local.get();t=e.tabsData||{}}return async function(){if(!n){n=!0;const e=await browser.tabs.query({currentWindow:!0,highlighted:!0});Object.keys(t).filter((t=>{if("autoSaveAll"!=t&&"autoSaveUnpinned"!=t&&"profileName"!=t)return!e.find((e=>e.id==t))})).forEach((e=>delete t[e])),await browser.storage.local.set({tabsData:t})}}(),void 0===e||t[e]||(t[e]={}),t}async function i(e){t=e,await browser.storage.local.set({tabsData:e})}setTimeout((()=>s().then((e=>t=e))),0);const c="-",l="__Default_Settings__",d="__Disabled_Settings__",u="regexp:",f={removeHiddenElements:!0,removeUnusedStyles:!0,removeUnusedFonts:!0,removeFrames:!1,removeImports:!0,removeScripts:!0,compressHTML:!0,compressCSS:!1,loadDeferredImages:!0,loadDeferredImagesMaxIdleTime:1500,loadDeferredImagesBlockCookies:!1,loadDeferredImagesBlockStorage:!1,loadDeferredImagesKeepZoomLevel:!1,filenameTemplate:"{page-title} ({date-locale} {time-locale}).html",infobarTemplate:"",includeInfobar:!1,confirmInfobarContent:!1,autoClose:!1,confirmFilename:!1,filenameConflictAction:"uniquify",filenameMaxLength:192,filenameMaxLengthUnit:"bytes",filenameReplacedCharacters:["~","+","\\\\","?","%","*",":","|",'"',"<",">","\0-",""],filenameReplacementCharacter:"_",contextMenuEnabled:!0,tabMenuEnabled:!0,browserActionMenuEnabled:!0,shadowEnabled:!0,logsEnabled:!0,progressBarEnabled:!0,maxResourceSizeEnabled:!1,maxResourceSize:10,removeAudioSrc:!0,removeVideoSrc:!0,displayInfobar:!0,displayStats:!1,backgroundSave:!/Mobile.*Firefox/.test(navigator.userAgent),defaultEditorMode:"normal",applySystemTheme:!0,autoSaveDelay:1,autoSaveLoad:!1,autoSaveUnload:!1,autoSaveLoadOrUnload:!0,autoSaveDiscard:!1,autoSaveRemove:!1,autoSaveRepeat:!1,autoSaveRepeatDelay:10,removeAlternativeFonts:!0,removeAlternativeMedias:!0,removeAlternativeImages:!0,groupDuplicateImages:!0,saveRawPage:!1,saveToClipboard:!1,addProof:!1,saveToGDrive:!1,saveToGitHub:!1,githubToken:"",githubUser:"",githubRepository:"SingleFile-Archives",githubBranch:"main",saveWithCompanion:!1,forceWebAuthFlow:!1,extractAuthCode:!0,resolveFragmentIdentifierURLs:!1,userScriptEnabled:!1,openEditor:!1,openSavedPage:!1,autoOpenEditor:!1,saveCreatedBookmarks:!1,allowedBookmarkFolders:[],ignoredBookmarkFolders:[],replaceBookmarkURL:!0,saveFavicon:!0,includeBOM:!1,warnUnsavedPage:!0,autoSaveExternalSave:!1,insertMetaNoIndex:!1,insertMetaCSP:!0,passReferrerOnError:!1,insertSingleFileComment:!0,blockMixedContent:!1,saveOriginalURLs:!1,acceptHeaders:{font:"application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8",image:"image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8",stylesheet:"text/css,*/*;q=0.1",script:"*/*",document:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},moveStylesInHead:!1,woleetKey:""};let h,m=w();async function w(){const{sync:e}=await browser.storage.local.get();h=e?browser.storage.sync:browser.storage.local;const t=await h.get();if(t.profiles)t.rules||(t.rules=[]),Object.keys(t.profiles).forEach((e=>p(t.profiles[e]))),await h.remove(["profiles","defaultProfile","rules"]),await h.set({profiles:t.profiles,rules:t.rules});else{const e=t;delete e.tabsData,p(e);const a={profiles:{},rules:[]};a.profiles.__Default_Settings__=e,h.remove(Object.keys(f)),await h.set(a)}t.maxParallelWorkers||await h.set({maxParallelWorkers:navigator.hardwareConcurrency||4})}function p(e){Object.keys(f).forEach((t=>function(e,t){void 0===e[t]&&(e[t]=f[t])}(e,t)))}async function b(e,t){const a=await g(),n=a.rules.filter((e=>v(e)));let r=n.sort(y).find((t=>e&&e.match(new RegExp(t.url.split(u)[1]))));if(!r){const n=a.rules.filter((e=>!v(e)));r=n.sort(y).find((a=>!t&&"*"==a.url||e&&e.includes(a.url)))}return r}async function g(){return await m,h.get(["profiles","rules","maxParallelWorkers"])}function y(e,t){return t.url.length-e.url.length}function v(e){return e.url.toLowerCase().startsWith(u)}async function k(t){if(t.method.endsWith(".deleteRules")&&await async function(e){const t=await g();t.rules=t.rules=e?t.rules.filter((t=>t.autoSaveProfile!=e&&t.profile!=e)):[],await h.set({rules:t.rules})}(t.profileName),t.method.endsWith(".deleteRule")&&await async function(e){if(!e)throw new Error("URL is empty");const t=await g();t.rules=t.rules.filter((t=>t.url!=e)),await h.set({rules:t.rules})}(t.url),t.method.endsWith(".addRule")&&await S(t.url,t.profileName,t.autoSaveProfileName),t.method.endsWith(".createProfile")&&await async function(e,t){const a=await g();if(Object.keys(a.profiles).includes(e))throw new Error("Duplicate profile name");a.profiles[e]=JSON.parse(JSON.stringify(a.profiles[t])),await h.set({profiles:a.profiles})}(t.profileName,t.fromProfileName||l),t.method.endsWith(".renameProfile")&&await async function(e,t){const[a,n]=await Promise.all([g(),s()]);if(!Object.keys(a.profiles).includes(e))throw new Error("Profile not found");if(Object.keys(a.profiles).includes(t))throw new Error("Duplicate profile name");if(e==l)throw new Error("Default settings cannot be renamed");n.profileName==e&&(n.profileName=t,await i(n));a.profiles[t]=a.profiles[e],a.rules.forEach((a=>{a.profile==e&&(a.profile=t),a.autoSaveProfile==e&&(a.autoSaveProfile=t)})),delete a.profiles[e],await h.set({profiles:a.profiles,rules:a.rules})}(t.profileName,t.newProfileName),t.method.endsWith(".deleteProfile")&&await async function(e){const[t,a]=await Promise.all([g(),s()]);if(!Object.keys(t.profiles).includes(e))throw new Error("Profile not found");if(e==l)throw new Error("Default settings cannot be deleted");a.profileName==e&&(delete a.profileName,await i(a));t.rules.forEach((t=>{t.profile==e&&(t.profile=l),t.autoSaveProfile==e&&(t.autoSaveProfile=l)})),delete t.profiles[e],await h.set({profiles:t.profiles,rules:t.rules})}(t.profileName),t.method.endsWith(".resetProfiles")&&await async function(){await m;const e=await s();delete e.profileName,await i(e),await h.remove(["profiles","rules","maxParallelWorkers"]),await browser.storage.local.set({sync:!1}),h=browser.storage.local,await w()}(),t.method.endsWith(".resetProfile")&&await async function(e){const t=await g();if(!Object.keys(t.profiles).includes(e))throw new Error("Profile not found");t.profiles[e]=f,await h.set({profiles:t.profiles})}(t.profileName),t.method.endsWith(".importConfig")&&await async function(e){await h.remove(["profiles","rules","maxParallelWorkers"]),await h.set({profiles:e.profiles,rules:e.rules,maxParallelWorkers:e.maxParallelWorkers}),await w()}(t.config),t.method.endsWith(".updateProfile")&&await async function(e,t){const a=await g();if(!Object.keys(a.profiles).includes(e))throw new Error("Profile not found");Object.keys(t).forEach((n=>a.profiles[e][n]=t[n])),await h.set({profiles:a.profiles})}(t.profileName,t.profile),t.method.endsWith(".updateRule")&&await T(t.url,t.newUrl,t.profileName,t.autoSaveProfileName),t.method.endsWith(".getConstants"))return{DISABLED_PROFILE_NAME:d,DEFAULT_PROFILE_NAME:l,CURRENT_PROFILE_NAME:c};if(t.method.endsWith(".getRules"))return async function(){return(await g()).rules}();if(t.method.endsWith(".getProfiles"))return I();if(t.method.endsWith(".exportConfig"))return async function(){const t=await g(),a=URL.createObjectURL(new Blob([JSON.stringify({profiles:t.profiles,rules:t.rules,maxParallelWorkers:t.maxParallelWorkers},null,2)],{type:"text/json"})),n={url:a,filename:`singlefile-settings-${(new Date).toISOString().replace(/:/g,"_")}.json`,saveAs:!0};try{await e(n,"_")}finally{URL.revokeObjectURL(a)}}();if(t.method.endsWith(".enableSync")){await browser.storage.local.set({sync:!0});const e=await browser.storage.sync.get();if(!e||!e.profiles){const e=await browser.storage.local.get();await browser.storage.sync.set({profiles:e.profiles,rules:e.rules,maxParallelWorkers:e.maxParallelWorkers})}return h=browser.storage.sync,{}}if(t.method.endsWith(".disableSync")){await browser.storage.local.set({sync:!1});const e=await browser.storage.sync.get();e&&e.profiles&&await browser.storage.local.set({profiles:e.profiles,rules:e.rules,maxParallelWorkers:e.maxParallelWorkers}),h=browser.storage.local}return t.method.endsWith(".isSync")?{sync:(await browser.storage.local.get()).sync}:{}}async function I(){return(await g()).profiles}async function x(e,t){const[a,n,r]=await Promise.all([g(),b(e),s()]),o=r.profileName||l;let i;if(n){const e=n[t?"autoSaveProfile":"profile"];i=e==c?o:e}else i=o;return Object.assign({profileName:i},a.profiles[i])}async function S(e,t,a){if(!e)throw new Error("URL is empty");const n=await g();if(n.rules.find((t=>t.url==e)))throw new Error("URL already exists");n.rules.push({url:e,profile:t,autoSaveProfile:a}),await h.set({rules:n.rules})}async function T(e,t,a,n){if(!e||!t)throw new Error("URL is empty");const r=await g(),o=r.rules.find((t=>t.url==e));if(!o)throw new Error("URL not found");if(r.rules.find((a=>a.url==t&&a.url!=e)))throw new Error("New URL already exists");o.url=t,o.profile=a,o.autoSaveProfile=n,await h.set({rules:r.rules})}async function E(){return(await h.get()).authInfo}async function P(e){await h.set({authInfo:e})}async function M(){let e=E();e.revokableAccessToken?P({revokableAccessToken:e.revokableAccessToken}):await h.remove(["authInfo"])}async function W(e){if(e){const[t,a]=await Promise.all([s(),b(e.url)]);return Boolean(t.autoSaveAll||t.autoSaveUnpinned&&!e.pinned||t[e.id]&&t[e.id].autoSave)&&(!a||a.autoSaveProfile!=d)}}const A=33554432,L="/extension/ui/pages/editor.html",R=new Map,C=new Map,U=browser.runtime.getURL(L);function B(e){return e.url==U}const _=new Map,D="x-single-file-request-id",O=8388608;async function j(e,t,a){for(let n=0;n*OO,r.truncated?(r.finished=(n+1)*O>a.array.length,r.array=a.array.slice(n*O,(n+1)*O)):r.array=a.array,await browser.tabs.sendMessage(e,r)}return{}}function N(e,t={},a){return new Promise(((n,r)=>{const o=new XMLHttpRequest;if(o.withCredentials=!0,o.responseType="arraybuffer",o.onerror=e=>r(new Error(e.detail)),o.onreadystatechange=()=>{o.readyState==XMLHttpRequest.DONE&&(o.status||o.response.byteLength?401!=o.status&&403!=o.status&&404!=o.status||a?n({array:Array.from(new Uint8Array(o.response)),headers:{"content-type":o.getResponseHeader("Content-Type")},status:o.status}):N(e,t,!0).then(n).catch(r):r())},o.open("GET",e,!0),t.headers)for(const e of Object.entries(t.headers))o.setRequestHeader(e[0],e[1]);if(a){const e=String(Math.random()).substring(2);!function(e,t){_.set(e,t)}(e,t.referrer),o.setRequestHeader(D,e)}o.send()}))}browser.runtime.onMessage.addListener(((e,t)=>{if(e.method&&e.method.startsWith("singlefile.fetch"))return new Promise((a=>{(async function(e,t){if("singlefile.fetch"==e.method)try{const a=await N(e.url,{referrer:e.referrer,headers:e.headers});return j(t.tab.id,e.requestId,a)}catch(a){return j(t.tab.id,e.requestId,{error:a.message,arrray:[]})}else if("singlefile.fetchFrame"==e.method)return browser.tabs.sendMessage(t.tab.id,e)})(e,t).then(a).catch((e=>a({error:e&&e.toString()})))}))}));let q=!1;function F(e){return e.method.endsWith(".enableReferrerOnError")?(H(),{}):e.method.endsWith(".disableReferrerOnError")?(function(){try{browser.webRequest.onBeforeSendHeaders.removeListener(z)}catch(e){}q=!1}(),{}):void 0}function z(e){if(q){let t=e.requestHeaders.find((e=>e.name===D));if(t){e.requestHeaders=e.requestHeaders.filter((e=>e.name!==D));const a=_.get(t.value);if(a){_.delete(t.value);if(!e.requestHeaders.find((e=>"referer"===e.name.toLowerCase())))return e.requestHeaders.push({name:"Referer",value:a}),{requestHeaders:e.requestHeaders}}}}}function H(){if(!q){try{browser.webRequest.onBeforeSendHeaders.addListener(z,{urls:[""]},["blocking","requestHeaders","extraHeaders"])}catch(e){browser.webRequest.onBeforeSendHeaders.addListener(z,{urls:[""]},["blocking","requestHeaders"])}q=!0}}const J=new Map;async function G(e){return(await browser.tabs.query(e)).sort(((e,t)=>e.index-t.index))}const K="/extension/ui/resources/icon_128.png",$="/extension/ui/resources/icon_128_wait",X=browser.i18n.getMessage("buttonDefaultTooltip"),Y=browser.i18n.getMessage("buttonBlockedTooltip"),Z=browser.i18n.getMessage("buttonInitializingBadge"),V=browser.i18n.getMessage("buttonInitializingTooltip"),Q=browser.i18n.getMessage("buttonErrorBadge"),ee=browser.i18n.getMessage("buttonBlockedBadge"),te=browser.i18n.getMessage("buttonOKBadge"),ae=browser.i18n.getMessage("buttonSaveProgressTooltip"),ne=browser.i18n.getMessage("buttonUploadProgressTooltip"),re=browser.i18n.getMessage("buttonAutoSaveActiveBadge"),oe=browser.i18n.getMessage("buttonAutoSaveActiveTooltip"),se=[2,147,20,192],ie=[4,229,36,192],ce={default:{setBadgeBackgroundColor:{color:se},setBadgeText:{text:""},setTitle:{title:X},setIcon:{path:K}},inject:{setBadgeBackgroundColor:{color:se},setBadgeText:{text:Z},setTitle:{title:V}},execute:{setBadgeBackgroundColor:{color:ie},setBadgeText:{text:Z}},progress:{setBadgeBackgroundColor:{color:ie},setBadgeText:{text:""}},edit:{setBadgeBackgroundColor:{color:se},setBadgeText:{text:""},setTitle:{title:X},setIcon:{path:K}},end:{setBadgeBackgroundColor:{color:ie},setBadgeText:{text:te},setTitle:{title:X},setIcon:{path:K}},error:{setBadgeBackgroundColor:{color:[229,4,12,192]},setBadgeText:{text:Q},setTitle:{title:""},setIcon:{path:K}},forbidden:{setBadgeBackgroundColor:{color:[255,255,255,1]},setBadgeText:{text:ee},setTitle:{title:Y},setIcon:{path:K}},autosave:{inject:{setBadgeBackgroundColor:{color:[64,64,64,192]},setBadgeText:{text:re},setTitle:{title:oe},setIcon:{path:K}},default:{setBadgeBackgroundColor:{color:[208,208,208,192]},setBadgeText:{text:re},setTitle:{title:oe},setIcon:{path:K}}}};let le;function de(e,t){if(e.method.endsWith(".processInit")){delete o(t.tab.id)[t.tab.id].button,we(t.tab)}var a,n,r;return e.method.endsWith(".processProgress")&&e.maxIndex&&(a=t.tab.id,n=e.index,r=e.maxIndex,me(a,n,r,ae)),e.method.endsWith(".processEnd")&&fe(t.tab.id),e.method.endsWith(".processError")&&(e.error&&console.error("Initialization error",e.error),ue(t.tab.id)),e.method.endsWith(".processCancelled")&&he(t.tab),Promise.resolve({})}function ue(e){pe(e,ge("error"))}function fe(e,t){pe(e,t?ge("default",!0):ge("end"))}function he(e){we(e)}function me(e,t,a,n){const r=Math.max(Math.min(20,Math.floor(t/a*20)),0),o=Math.min(Math.floor(t/a*8),8),s=$+o+".png",i=ge("progress");i.setTitle={title:n+5*r+"%"},i.setIcon={path:s},pe(e,i)}async function we(e){const t=ge("default",await W(e));await pe(e.id,t)}async function pe(e,t){const a=o(e);if(t){a[e].button||(a[e].button={lastState:null});const n=a[e].button.lastState||{},r={};Object.keys(t).forEach((e=>{void 0!==t[e]&&JSON.stringify(n[e])!=JSON.stringify(t[e])&&(r[e]=t[e])})),Object.keys(r).length&&(a[e].button.lastState=t,await async function(e,t){for(const a of Object.keys(t))await be(e,a,t[a])}(e,r))}}async function be(e,t,a){if(browser.browserAction[t]){const n=JSON.parse(JSON.stringify(a));n.tabId=e,await browser.browserAction[t](n)}}function ge(e,t){return JSON.parse(JSON.stringify(t?ce.autosave[e]:ce[e]))}browser.browserAction.onClicked.addListener((async e=>{const t=await G({currentWindow:!0,highlighted:!0});t.length<=1?function(e){le.isSavingTab(e)?le.cancelTab(e.id):le.saveTabs([e])}(e):le.saveTabs(t)}));const ye=browser.menus,ve=ye&&ye.onClicked&&ye.create&&ye.update&&ye.removeAll,ke="save-page",Ie="edit-and-save-page",xe="save-with-profile",Se="save-selected-links",Te="view-pendings",Ee="select-profile",Pe="wasve-with-profile-",Me="select-profile-",We="associate-with-profile",Ae="associate-with-profile-",Le="save-selected",Re="save-frame",Ce="save-tabs",Ue="save-selected-tabs",Be="save-unpinned-tabs",_e="save-all-tabs",De="button-save-selected-tabs",Oe="button-save-unpinned-tabs",je="button-save-all-tabs",Ne="auto-save",qe="auto-save-disabled",Fe="auto-save-tab",ze="auto-save-unpinned",He="auto-save-all",Je=browser.i18n.getMessage("menuCreateDomainRule"),Ge=browser.i18n.getMessage("menuUpdateRule"),Ke=browser.i18n.getMessage("menuSavePage"),$e=browser.i18n.getMessage("menuSaveWithProfile"),Xe=browser.i18n.getMessage("menuSaveSelectedLinks"),Ye=browser.i18n.getMessage("menuEditPage"),Ze=browser.i18n.getMessage("menuEditAndSavePage"),Ve=browser.i18n.getMessage("menuViewPendingSaves"),Qe=browser.i18n.getMessage("menuSaveSelection"),et=browser.i18n.getMessage("menuSaveFrame"),tt=browser.i18n.getMessage("menuSaveTabs"),at=browser.i18n.getMessage("menuSaveSelectedTabs"),nt=browser.i18n.getMessage("menuSaveUnpinnedTabs"),rt=browser.i18n.getMessage("menuSaveAllTabs"),ot=browser.i18n.getMessage("menuSelectProfile"),st=browser.i18n.getMessage("profileDefaultSettings"),it=browser.i18n.getMessage("menuAutoSave"),ct=browser.i18n.getMessage("menuAutoSaveDisabled"),lt=browser.i18n.getMessage("menuAutoSaveTab"),dt=browser.i18n.getMessage("menuAutoSaveUnpinnedTabs"),ut=browser.i18n.getMessage("menuAutoSaveAllTabs"),ft=[Ie,Se,Le,Re,Ne,We],ht=new Map,mt=new Map;let wt,pt,bt,gt=!0,yt=!0,vt=new Map;async function kt(e){const[t,a]=await Promise.all([I(),s()]),n=await x(e&&e.url);if(ve&&n){const r=["page","frame","image","link","video","audio","selection"],o=[];if(n.browserActionMenuEnabled&&o.push("browser_action"),n.tabMenuEnabled)try{ye.create({id:"temporary-id",contexts:["tab"],title:"title"}),o.push("tab")}catch(e){n.tabMenuEnabled=!1}await ye.removeAll();const s=o.concat(...r),i=n.contextMenuEnabled?s:o;if(ye.create({id:ke,contexts:i,title:Ke}),ye.create({id:Ie,contexts:i,title:Ze}),ye.create({id:Se,contexts:n.contextMenuEnabled?o.concat(["selection"]):o,title:Xe}),Object.keys(t).length>1&&ye.create({id:xe,contexts:i,title:$e}),n.contextMenuEnabled&&ye.create({id:"separator-1",contexts:r,type:"separator"}),ye.create({id:Le,contexts:i,title:Qe}),n.contextMenuEnabled&&ye.create({id:Re,contexts:["frame"],title:et}),ye.create({id:Ce,contexts:o,title:tt}),ye.create({id:De,contexts:o,title:at,parentId:Ce}),ye.create({id:Oe,contexts:o,title:nt,parentId:Ce}),ye.create({id:je,contexts:o,title:rt,parentId:Ce}),n.contextMenuEnabled&&(ye.create({id:Ue,contexts:r,title:at}),ye.create({id:Be,contexts:r,title:nt}),ye.create({id:_e,contexts:r,title:rt}),ye.create({id:"separator-2",contexts:r,type:"separator"})),Object.keys(t).length>1){ye.create({id:Ee,title:ot,contexts:i}),ye.create({id:"wasve-with-profile-default",contexts:i,title:st,parentId:xe});const o="select-profile-default",s=!a.profileName||a.profileName==l;let d;ye.create({id:o,type:"radio",contexts:i,title:st,checked:s,parentId:Ee}),ht.set(o,s),ye.create({id:We,title:Je,contexts:i}),mt.set(We,Je),e&&e.url&&(d=await b(e.url,!0));const u="associate-with-profile-current",f=!d||d.profile==c;ye.create({id:u,type:"radio",contexts:i,title:c,checked:f,parentId:We}),ht.set(u,f);const h="associate-with-profile-default",m=Boolean(d)&&d.profile==l;ye.create({id:h,type:"radio",contexts:i,title:st,checked:m,parentId:We}),ht.set(h,m),vt=new Map,Object.keys(t).forEach(((e,t)=>{if(e!=l){let n=Pe+t;ye.create({id:n,contexts:i,title:e,parentId:xe}),n=Me+t;let r=a.profileName==e;ye.create({id:n,type:"radio",contexts:i,title:e,checked:r,parentId:Ee}),ht.set(n,r),n=Ae+t,r=Boolean(d)&&d.profile==e,ye.create({id:n,type:"radio",contexts:i,title:e,checked:r,parentId:We}),ht.set(n,r),vt.set(e,t)}})),n.contextMenuEnabled&&ye.create({id:"separator-3",contexts:r,type:"separator"})}ye.create({id:Ne,contexts:i,title:it}),ye.create({id:qe,type:"radio",title:ct,contexts:i,checked:!0,parentId:Ne}),ht.set(qe,!0),ye.create({id:Fe,type:"radio",title:lt,contexts:i,checked:!1,parentId:Ne}),ht.set(Fe,!1),ye.create({id:ze,type:"radio",title:dt,contexts:i,checked:!1,parentId:Ne}),ht.set(ze,!1),ye.create({id:He,type:"radio",title:ut,contexts:i,checked:!1,parentId:Ne}),ht.set(He,!1),ye.create({id:"separator-4",contexts:i,type:"separator"}),ye.create({id:Te,contexts:i,title:Ve})}wt=!0,pt&&(pt=!1,(await browser.tabs.query({})).forEach((async e=>await xt(e))))}async function It(e){const t=await s(e.id);await async function(){const e=await browser.tabs.query({});return Promise.all(e.map((async e=>{const[t,a]=await Promise.all([x(e.url,!0),W(e)]);try{await browser.tabs.sendMessage(e.id,{method:"content.init",autoSaveEnabled:a,options:t})}catch(e){}})))}(),await we(e);try{await browser.runtime.sendMessage({method:"options.refresh",profileName:t.profileName})}catch(e){}}async function xt(e){if(ve&&wt){const t=[],a=await s(e.id);if(a[e.id].editorDetected)St(!1);else if(St(!0),t.push(Et(qe,!a[e.id].autoSave)),t.push(Et(Fe,a[e.id].autoSave)),t.push(Et(ze,Boolean(a.autoSaveUnpinned))),t.push(Et(He,Boolean(a.autoSaveAll))),e&&e.url){const n=await x(e.url);t.push(async function(e,t){const a=gt;gt=t,(void 0===a||a!=t)&&await kt(e)}(e,n.contextMenuEnabled)),t.push(Tt(Ie,a[e.id].savedPageDetected?Ye:Ze)),t.push(ye.update(Le,{visible:!n.saveRawPage})),t.push(ye.update(Ie,{visible:!n.openEditor||a[e.id].savedPageDetected}));let r="associate-with-profile-default",o=Je;const[s,i]=await Promise.all([I(),b(e.url)]);if(i){const e=vt.get(i.profile);e&&(r=Ae+e,o=Ge)}Object.keys(s).length>1&&(Object.keys(s).forEach(((e,a)=>{e==l?t.push(Et("associate-with-profile-default","associate-with-profile-default"==r)):t.push(Et(Ae+a,r==Ae+a))})),t.push(Tt(We,o)))}await Promise.all(t)}}async function St(e){const t=yt;if(yt=e,void 0===t||t!=e){const t=[];try{ft.forEach((a=>t.push(ye.update(a,{visible:e})))),await Promise.all(t)}catch(e){}}}function Tt(e,t){const a=mt.get(e);return mt.set(e,t),void 0===a||a!=t?ye.update(e,{title:t}):void 0}async function Et(e,t){t=Boolean(t),ht.set(e,t),await ye.update(e,{checked:t})}Promise.resolve().then((async function(){ve&&(kt(),ye.onClicked.addListener((async(e,t)=>{if(e.menuItemId==ke&&(e.linkUrl?bt.saveUrls([e.linkUrl]):bt.saveTabs([t])),e.menuItemId==Ie){(await s(t.id))[t.id].savedPageDetected?bt.openEditor(t):e.linkUrl?bt.saveUrls([e.linkUrl],{openEditor:!0}):bt.saveTabs([t],{openEditor:!0})}if(e.menuItemId==Se&&bt.saveSelectedLinks(t),e.menuItemId==Te&&await browser.tabs.create({active:!0,url:"/extension/ui/pages/pendings.html"}),e.menuItemId==Le&&bt.saveTabs([t],{selected:!0}),e.menuItemId==Re&&bt.saveTabs([t],{frameId:e.frameId}),e.menuItemId==Ue||e.menuItemId==De){const e=await G({currentWindow:!0,highlighted:!0});bt.saveTabs(e)}if(e.menuItemId==Be||e.menuItemId==Oe){const e=await G({currentWindow:!0,pinned:!1});bt.saveTabs(e)}if(e.menuItemId==_e||e.menuItemId==je){const e=await G({currentWindow:!0});bt.saveTabs(e)}if(e.menuItemId==Fe){const e=await s(t.id);e[t.id].autoSave=!0,await i(e),It(t)}if(e.menuItemId==qe){const e=await s();Object.keys(e).forEach((t=>{"object"==typeof e[t]&&e[t].autoSave&&(e[t].autoSave=!1)})),e.autoSaveUnpinned=e.autoSaveAll=!1,await i(e),It(t)}if(e.menuItemId==He){const a=await s();a.autoSaveAll=e.checked,await i(a),It(t)}if(e.menuItemId==ze){const a=await s();a.autoSaveUnpinned=e.checked,await i(a),It(t)}if(e.menuItemId.startsWith(Pe)){const a=await I(),n=e.menuItemId.split(Pe)[1];let r;if("default"==n)r=l;else{const e=Number(n);r=Object.keys(a)[e]}a[r].profileName=r,bt.saveTabs([t],a[r])}if(e.menuItemId.startsWith(Me)){const[a,n]=await Promise.all([I(),s()]),r=e.menuItemId.split(Me)[1];if("default"==r)n.profileName=l;else{const e=Number(r);n.profileName=Object.keys(a)[e]}await i(n),It(t)}if(e.menuItemId.startsWith(Ae)){const[a,n]=await Promise.all([I(),b(t.url,!0)]),r=e.menuItemId.split(Ae)[1];let o;if("default"==r)o=l;else if("current"==r)o=c;else{const e=Number(r);o=Object.keys(a)[e]}n?await T(n.url,n.url,o,o):(await Tt(We,Ge),await S(new URL(t.url).hostname,o,o))}})),wt?pt=!0:(await browser.tabs.query({})).forEach((async e=>await xt(e))))}));const Pt=browser.commands;let Mt,Wt,At;function Lt(e,t){return e.method.endsWith(".refreshMenu")?function(e){if(e.method.endsWith("refreshMenu"))return kt(),Promise.resolve({})}(e):de(e,t)}function Rt(e){!function(e){pe(e.id,ge("forbidden"))}(e)}function Ct(e,t,a){!function(e,t,a){let n;a?n=ge("inject",!0):(n=ge(1==t?"inject":"execute"),n.setTitle={title:V+" ("+t+"/2)"},n.setIcon={path:$+"0.png"}),pe(e,n)}(e,t,a)}async function Ut(e,t,a){ue(e),t&&await browser.tabs.sendMessage(e,{method:"content.error",error:t.toString(),link:a})}function Bt(e){!function(e){pe(e,ge("edit"))}(e)}function _t(e,t){fe(e,t)}function Dt(e,t,a){!function(e,t,a){me(e,t,a,ne)}(e,t,a)}function Ot(e){xt(e)}Pt&&Pt.onCommand&&Pt.onCommand.addListener&&Pt.onCommand.addListener((async e=>{if("save-selected-tabs"==e){const e=await G({currentWindow:!0,highlighted:!0});Mt.saveTabs(e,{optionallySelected:!0})}if("save-all-tabs"==e){const e=await G({currentWindow:!0});Mt.saveTabs(e)}}));const jt=["dist/chrome-browser-polyfill.js","dist/single-file.js"],Nt=["dist/chrome-browser-polyfill.js","dist/single-file-frames.js"];async function qt(e,t){let a;if(await async function(e){const t=e.extensionScriptFiles||[];Wt||At||([Wt,At]=await Promise.all([Ft(jt.concat(t)),Ft(Nt)]))}(t),!t.removeFrames)try{await browser.tabs.executeScript(e,{code:At,allFrames:!0,matchAboutBlank:!0,runAt:"document_start"})}catch(e){}try{await browser.tabs.executeScript(e,{code:Wt,allFrames:!1,runAt:"document_idle"}),a=!0}catch(e){}return a&&t.frameId&&await browser.tabs.executeScript(e,{code:"document.documentElement.dataset.requestedFrameId = true",frameId:t.frameId,matchAboutBlank:!0,runAt:"document_start"}),a}async function Ft(e){const t=e.map((async e=>{if("function"==typeof e)return"("+e.toString()+")();";{const t=await fetch(browser.runtime.getURL("../../../"+e));return(new TextDecoder).decode(await t.arrayBuffer())}}));let a="";for(const e of t)a+=await e;return a}const zt="single-file-response-fetch",Ht=(e,t)=>window.fetch(e,t);let Jt=0,Gt=new Map;async function Kt(e,t={}){try{let a=await Ht(e,{cache:"force-cache",headers:t.headers});return 401!=a.status&&403!=a.status&&404!=a.status||(a=await Yt(e)),a}catch(a){Jt++;const n=new Promise(((e,t)=>Gt.set(Jt,{resolve:e,reject:t})));return await Xt({method:"singlefile.fetch",url:e,requestId:Jt,referrer:t.referrer,headers:t.headers}),n}}async function $t(e,t){const a=await Xt({method:"singlefile.fetchFrame",url:e,frameId:t.frameId,referrer:t.referrer,headers:t.headers});return{status:a.status,headers:new Map(a.headers),arrayBuffer:async()=>new Uint8Array(a.array).buffer}}async function Xt(e){const t=await browser.runtime.sendMessage(e);if(!t||t.error)throw new Error(t&&t.error&&t.error.toString());return t}function Yt(e){return new Promise(((t,a)=>{var n,r,o,s;n=new CustomEvent("single-file-request-fetch",{detail:e}),window.dispatchEvent(n),r=zt,o=function n(r){var o,s,i;r.detail?r.detail.url==e&&(o=zt,s=n,i=!1,window.removeEventListener(o,s,i),r.detail.response?t({status:r.detail.status,headers:new Map(r.detail.headers),arrayBuffer:async()=>r.detail.response}):a(r.detail.error)):a()},s=!1,window.addEventListener(r,o,s)}))}function Zt(e,t){return qt(e,t)}browser.runtime.onMessage.addListener((e=>"singlefile.fetchFrame"==e.method&&window.frameId&&window.frameId==e.frameId?async function(e){try{let t=await Ht(e.url,{cache:"force-cache",headers:e.headers});return 401!=t.status&&403!=t.status&&404!=t.status||(t=await Promise.race([Yt(e.url),new Promise(((e,t)=>setTimeout((()=>t()),5e3)))])),{status:t.status,headers:[...t.headers],array:Array.from(new Uint8Array(await t.arrayBuffer()))}}catch(e){return{error:e&&e.toString()}}}(e):"singlefile.fetchResponse"==e.method?async function(e){const t=Gt.get(e.requestId);t&&(e.error?(t.reject(new Error(e.error)),Gt.delete(e.requestId)):(e.truncated&&(t.array?t.array=t.array.concat(e.array):(t.array=e.array,Gt.set(e.requestId,t)),e.finished&&(e.array=t.array)),e.truncated&&!e.finished||(t.resolve({status:e.status,headers:{get:t=>e.headers&&e.headers[t]},arrayBuffer:async()=>new Uint8Array(e.array).buffer}),Gt.delete(e.requestId))));return{}}(e):void 0));const Vt="Could not establish connection. Receiving end does not exist.",Qt="The message port closed before a response was received.",ea="Message manager disconnected",ta="Cannot access contents of url ",aa="pending",na="processing",ra=["dist/infobar.js","dist/extension.js"],oa=[];let sa,ia=0;var ca;async function la(e,t={}){await fa(),await Promise.all(e.map((async e=>{const a=await x(e);Object.keys(t).forEach((e=>a[e]=t[e])),a.autoClose=!0,a.extensionScriptFiles=ra,a.passReferrerOnError&&await H(),ua({tab:{url:e},status:aa,options:a,method:"content.save"})}))),ha()}async function da(e,t={}){await fa(),await Promise.all(e.map((async e=>{const a=e.id,n=await x(e.url);if(Object.keys(t).forEach((e=>n[e]=t[e])),n.tabId=a,n.tabIndex=e.index,n.extensionScriptFiles=ra,n.passReferrerOnError&&await H(),t.autoSave){if(W(e)){ma(ua({status:na,tab:e,options:n,method:"content.autosave"}))}}else{Ct(a,1);await Zt(a,n)||B(e)?(Ct(a,2),ua({status:aa,tab:e,options:n,method:"content.save"})):Rt(e)}}))),ha()}function ua(e){const t={id:ia,status:e.status,tab:e.tab,options:e.options,method:e.method,done:function(){oa.splice(oa.findIndex((e=>e.id==this.id)),1),ha()}};return oa.push(t),ia++,t}async function fa(){sa||(sa=(await g()).maxParallelWorkers)}function ha(){const e=oa.filter((e=>e.status==na)).length;for(let t=0;te.status==aa));e&&ma(e)}}async function ma(e){const t=e.id;if(e.status=na,!e.tab.id){let t;try{const a=await async function(e){const t=await browser.tabs.create(e);return new Promise(((e,a)=>{function n(a,o){a==t.id&&"complete"==o.status&&(e(t),browser.tabs.onUpdated.removeListener(n),browser.tabs.onRemoved.removeListener(r))}function r(e){e==t.id&&(a(e),browser.tabs.onRemoved.removeListener(r))}browser.tabs.onUpdated.addListener(n),browser.tabs.onRemoved.addListener(r)}))}({url:e.tab.url,active:!1});e.tab.id=e.options.tabId=a.id,e.tab.index=e.options.tabIndex=a.index,Ct(e.tab.id,1),t=await Zt(e.tab.id,e.options)}catch(t){e.tab.id=t}if(!t)return void e.done();Ct(e.tab.id,2)}e.options.taskId=t;try{await browser.tabs.sendMessage(e.tab.id,{method:e.method,options:e.options})}catch(t){!t||t.message&&function(e){return e.message==Qt||e.message==Vt||e.message==ea||e.message.startsWith(ta+JSON.stringify(U))}(t)||(console.log(t.message?t.message:t),Ut(e.tab.id,t.message,t.link),e.done())}}function wa(e){const t=oa.find((t=>t.id==e));t&&(t.options.autoClose&&!t.cancelled&&browser.tabs.remove(t.tab.id),t.done())}function pa(e,t){const a=oa.find((t=>t.id==e));a&&(a.cancel=t)}function ba(e){Array.from(oa).filter((t=>t.tab.id==e&&!t.options.autoSave)).forEach(ya)}function ga(e){return oa.find((t=>t.id==e))}function ya(e){const t=e.tab.id;e.cancelled=!0,browser.tabs.sendMessage(t,{method:"content.cancelSave",options:{loadDeferredImages:e.options.loadDeferredImages,loadDeferredImagesKeepZoomLevel:e.options.loadDeferredImagesKeepZoomLevel}}),e.cancel&&e.cancel(),"content.autosave"==e.method&&_t(t,!0),function(e){he(e)}(e.tab),e.done()}function va(e){return{id:e.id,tabId:e.tab.id,index:e.tab.index,url:e.tab.url,title:e.tab.title,cancelled:e.cancelled,status:e.status}}(function(e){bt=e})(ca={isSavingTab:function(e){return Boolean(oa.find((t=>t.tab.id==e.id)))},saveTabs:da,saveUrls:la,cancelTab:ba,openEditor:function(e){browser.tabs.sendMessage(e.id,{method:"content.openEditor"})},saveSelectedLinks:async function(e){const t={extensionScriptFiles:ra,tabId:e.id,tabIndex:e.index};if(await Zt(e.id,t)){const t=await browser.tabs.sendMessage(e.id,{method:"content.getSelectedLinks"});t.urls&&t.urls.length&&await la(t.urls)}else Rt(e)}}),function(e){le=e}(ca),function(e){Mt=e}(ca);async function ka(e){const t=browser.runtime.connectNative("singlefile_companion");t.postMessage({method:"save",pageData:e}),await new Promise(((e,a)=>{t.onDisconnect.addListener((()=>{t.error?a(new Error(t.error.message+" (Companion)")):browser.runtime.lastError&&!browser.runtime.lastError.message.includes("Native host has exited")||e()}))}))}async function Ia(e){return e.method.endsWith(".saveCreatedBookmarks")?(xa(),{}):e.method.endsWith(".disable")?(async function(){let e;const t=await I();Object.keys(t).forEach((a=>e=e||!t[a].saveCreatedBookmarks)),e&&browser.bookmarks.onCreated.removeListener(Sa)}(),{}):void 0}async function xa(){try{browser.bookmarks.onCreated.removeListener(Sa)}catch(e){}let e;const t=await I();Object.keys(t).forEach((a=>{t[a].saveCreatedBookmarks&&(e=!0)})),e&&browser.bookmarks.onCreated.addListener(Sa)}async function Sa(e,t){const a=await browser.tabs.query({lastFocusedWindow:!0,active:!0}),n=await x(t.url);if(n.saveCreatedBookmarks){const o=await async function e(t,a=[]){if(t){const n=(await browser.bookmarks.get(t))[0];n&&n.title&&(a.unshift(n.title),await e(n.parentId,a))}return a}(t.parentId),s=n.allowedBookmarkFolders.toString(),i=o.find((e=>n.allowedBookmarkFolders.includes(e))),c=n.ignoredBookmarkFolders.toString(),l=o.find((e=>n.ignoredBookmarkFolders.includes(e)));if((s&&i||!s)&&(c&&!l||!c))if(a.length&&a[0].url==t.url)da(a,{bookmarkId:e,bookmarkFolders:o});else{const a=await browser.tabs.query({});if(a.length){const n=a.find((e=>e.url==t.url));n?da([n],{bookmarkId:e,bookmarkFolders:o}):t.url&&("about:blank"==t.url?browser.bookmarks.onChanged.addListener((function t(a,n){a==e&&n.url&&(browser.bookmarks.onChanged.removeListener(t),r(n.url))})):r(t.url))}}}function r(t){la([t],{bookmarkId:e})}}Promise.resolve().then(xa);async function Ta(e,t){let a=t||"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhYzZmZTMzMi0wODNjLTRjZmMtYmYxNC0xNWU5MTJmMWY4OWIiLCJpYXQiOjE1NzYxNzQzNDV9.n31j9ctJj7R1Vjwyc5yd1d6Cmg0NDnpwSaLWsqtZJQA";const n=await fetch("https://api.woleet.io/v1/anchor",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:"Bearer "+a},body:JSON.stringify({name:e,hash:e,public:!0})});if(401==n.status){const e=new Error("Your access token on Woleet is invalid. Go to __DOC_LINK__ to create your account.");throw e.link="https://app.woleet.io/",e}if(402==n.status){const e=new Error("You have no more credits on Woleet. Go to __DOC_LINK__ to recharge them.");throw e.link="https://app.woleet.io/",e}if(n.status>=400)throw new Error((n.statusText||"Error "+n.status)+" (Woleet)");return n.json()}const Ea="https://oauth2.googleapis.com/token",Pa="https://www.googleapis.com/drive/v3/files";let Ma,Wa=!0;class Aa{constructor(e){this.file=e.file,this.onProgress=e.onProgress,this.contentType=this.file.type||"application/octet-stream",this.metadata={name:e.filename,mimeType:this.contentType,parents:e.parents||["root"]},this.token=e.token,this.offset=0,this.chunkSize=e.chunkSize||524288}async upload(){const e=Oa(await fetch("https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable",{method:"POST",headers:{Authorization:"Bearer "+this.token,"Content-Type":"application/json","X-Upload-Content-Length":this.file.size,"X-Upload-Content-Type":this.contentType},body:JSON.stringify(this.metadata)})).headers.get("Location");if(this.url=e,!this.cancelled)return this.onProgress&&this.onProgress(0,this.file.size),_a(this)}}async function La(e,t){const a=await fetch(Ea,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"client_id="+e.clientId+"&grant_type=authorization_code&code="+t.code+"&redirect_uri="+e.redirectURI}),n=await Da(a);return e.accessToken=n.access_token,e.refreshToken=n.refresh_token,e.expirationDate=Date.now()+1e3*n.expires_in,{accessToken:e.accessToken,refreshToken:e.refreshToken,expirationDate:e.expirationDate}}function Ra(e,t={}){return e.redirectURI=encodeURIComponent("urn:ietf:wg:oauth:2.0:oob"+(t.auto?":auto":"")),e.authURL="https://accounts.google.com/o/oauth2/v2/auth?client_id="+e.clientId+"&response_type=code&access_type=offline&redirect_uri="+e.redirectURI+"&scope="+e.scopes.join(" "),e.authURL}function Ca(e={}){return Boolean(browser.identity&&browser.identity.getAuthToken)&&!e.forceWebAuthFlow}async function Ua(e,t,a=!0){const n=t.split("/");n.pop();const r=e.folderIds.get(n.join("/"));if(r)return r;let o="root";if(n.length){let r="";for(const s of n){r&&(r+="/"),r+=s;const n=e.folderIds.get(r);if(n)o=n;else try{o=await Ba(e,s,o),e.folderIds.set(r,o)}catch(n){if("path_not_found"==n.message&&a)return e.folderIds.clear(),Ua(e,t,!1);throw n}}}return o}async function Ba(e,t,a){const n=await async function(e,t,a){return Da(await fetch(Pa+"?q=mimeType = 'application/vnd.google-apps.folder' and name = '"+t+"' and trashed != true and '"+a+"' in parents",{headers:{Authorization:"Bearer "+e.accessToken}}))}(e,t,a);if(n.files.length)return n.files[0].id;{const n=await async function(e,t,a){return Da(await fetch(Pa,{method:"POST",headers:{Authorization:"Bearer "+e.accessToken,"Content-Type":"application/json"},body:JSON.stringify({name:t,parents:[a],mimeType:"application/vnd.google-apps.folder"})}))}(e,t,a);return n.id}}async function _a(e){let t=e.file,a=e.file.size;(e.offset||e.chunkSize)&&(e.chunkSize&&(a=Math.min(e.offset+e.chunkSize,e.file.size)),t=t.slice(e.offset,a));const n=await fetch(e.url,{method:"PUT",headers:{Authorization:"Bearer "+e.token,"Content-Type":e.contentType,"Content-Range":"bytes "+e.offset+"-"+(a-1)+"/"+e.file.size,"X-Upload-Content-Type":e.contentType},body:t});if(e.onProgress&&!e.cancelled&&e.onProgress(e.offset+e.chunkSize,e.file.size),200==n.status||201==n.status)return n.json();if(308==n.status){const t=n.headers.get("Range");if(t&&(e.offset=parseInt(t.match(/\d+/g).pop(),10)+1),e.cancelled)throw new Error("upload_cancelled");return _a(e)}Oa(n)}async function Da(e){e=Oa(e);const t=await e.json();if(t.error)throw new Error(t.error);return t}function Oa(e){if(200==e.status)return e;throw 404==e.status?new Error("path_not_found"):401==e.status?new Error("invalid_token"):new Error("unknown_error ("+e.status+")")}async function ja(e,t,a,n,r,o){for(;Ma;)await Ma;const s=new AbortController;return Ma=(async()=>{try{await async function({path:r,content:o,message:s=""},i){try{const c=await fetch(`https://api.github.com/repos/${t}/${a}/contents/${r.replace(/#/g,"%23")}`,{method:"PUT",headers:new Map([["Authorization",`token ${e}`],["Accept","application/vnd.github.v3+json"]]),body:JSON.stringify({content:btoa(unescape(encodeURIComponent(o))),message:s,branch:n}),signal:i}),l=await c.json();if(c.status<400)return l;throw new Error(l.message)}catch(e){if("AbortError"!=e.name)throw e}}({path:r,content:o},s.signal)}finally{Ma=null}})(),{cancelPush:()=>s.abort(),pushPromise:Ma}}const Na=new Map,qa="text/html",Fa=/([{}()^$&.*?/+|[\\\\]|\]|-)/g,za=browser.runtime.getManifest(),Ha=za.optional_permissions&&za.optional_permissions.includes("identity"),Ja=new class{constructor(e,t){this.clientId=e,this.scopes=t,this.folderIds=new Map,setInterval((()=>this.folderIds.clear()),6e4)}async auth(e={interactive:!0,auto:!0}){if(e.requestPermissionIdentity&&Wa)try{await browser.permissions.request({permissions:["identity"]}),Wa=!1}catch(e){}return Ca(e)?(this.accessToken=await browser.identity.getAuthToken({interactive:e.interactive}),{revokableAccessToken:this.accessToken}):(Ra(this,e),e.code?La(this,e):async function(e,t){let a;t.extractAuthCode&&t.extractAuthCode(Ra(e,t)).then((e=>a=e)).catch((()=>{}));try{if(browser.identity&&browser.identity.launchWebAuthFlow&&!t.forceWebAuthFlow)return await browser.identity.launchWebAuthFlow({interactive:t.interactive,url:e.authURL});if(t.launchWebAuthFlow)return await t.launchWebAuthFlow({url:e.authURL});throw new Error("auth_not_supported")}catch(n){if(n.message&&("code_required"==n.message||n.message.includes("access"))){if(t.auto||a||!t.promptAuthCode||(a=await t.promptAuthCode()),a)return t.code=a,await La(e,t);throw new Error("code_required")}throw n}}(this,e))}setAuthInfo(e,t){Ca(t)||(e?(this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationDate=e.expirationDate):(delete this.accessToken,delete this.refreshToken,delete this.expirationDate))}async refreshAuthToken(){if(this.refreshToken){const e=await fetch(Ea,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"client_id="+this.clientId+"&refresh_token="+this.refreshToken+"&grant_type=refresh_token"});if(400==e.status)throw new Error("unknown_token");const t=await Da(e);return this.accessToken=t.access_token,t.refresh_token&&(this.refreshToken=t.refresh_token),t.expires_in&&(this.expirationDate=Date.now()+1e3*t.expires_in),{accessToken:this.accessToken,refreshToken:this.refreshToken,expirationDate:this.expirationDate}}}async revokeAuthToken(e){if(e){if(browser.identity&&browser.identity.removeCachedAuthToken)try{await browser.identity.removeCachedAuthToken({token:e})}catch(e){}const t=await fetch("https://accounts.google.com/o/oauth2/revoke",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"token="+e});try{await Da(t)}catch(e){if("invalid_token"!=e.message)throw e}finally{delete this.accessToken,delete this.refreshToken,delete this.expirationDate}}}async upload(e,t,a,n=!0){const r=await Ua(this,e),o=e.split("/").pop(),s=new Aa({token:this.accessToken,file:t,parents:[r],filename:o,onProgress:a.onProgress});try{return{cancelUpload:()=>s.cancelled=!0,uploadPromise:s.upload()}}catch(r){if("path_not_found"==r.message&&n)return this.folderIds.clear(),this.upload(e,t,a,!1);throw r}}}("207618107333-3pj2pmelhnl4sf3rpctghs9cean3q8nj.apps.googleusercontent.com",["https://www.googleapis.com/auth/drive.file"]);async function Ga(e,t){if(e.method.endsWith(".download"))return async function(e,t){let a;e.truncated?(a=Na.get(t.id),a||(a=[],Na.set(t.id,a)),a.push(e.content),e.finished&&Na.delete(t.id)):e.content&&(a=[e.content]);e.truncated&&!e.finished||(e.openEditor?(Bt(t.id),await async function({tabIndex:e,content:t,filename:a}){const n={active:!0,url:L};null!=e&&(n.index=e);const r=await browser.tabs.create(n);R.set(r.id,{content:t,filename:a})}({tabIndex:t.index+1,filename:e.filename,content:a.join("")})):e.saveToClipboard?(e.content=a.join(""),function(e){const t="copy";function a(t){t.clipboardData.setData(qa,e.content),t.clipboardData.setData("text/plain",e.content),t.preventDefault()}document.addEventListener(t,a),document.execCommand(t),document.removeEventListener(t,a)}(e),_t(t.id)):await async function(e,t,a,n){try{if(n.saveToGDrive?await(await Xa(n.taskId,n.filename,new Blob(e,{type:qa}),{forceWebAuthFlow:n.forceWebAuthFlow,extractAuthCode:n.extractAuthCode},{onProgress:(e,a)=>Dt(t.id,e,a)})).uploadPromise:n.saveToGitHub?await(await $a(n.taskId,n.filename,e.join(""),n.githubToken,n.githubUser,n.githubRepository,n.githubBranch)).pushPromise:n.saveWithCompanion?await ka({filename:n.filename,content:n.content,filenameConflictAction:n.filenameConflictAction}):(n.url=URL.createObjectURL(new Blob(e,{type:qa})),await Ya(n,{confirmFilename:n.confirmFilename,incognito:a,filenameConflictAction:n.filenameConflictAction,filenameReplacementCharacter:n.filenameReplacementCharacter,includeInfobar:n.includeInfobar})),_t(t.id),n.openSavedPage){const a={active:!0,url:URL.createObjectURL(new Blob(e,{type:qa}))};null!=t.index&&(a.index=t.index+1),browser.tabs.create(a)}}catch(e){e.message&&"upload_cancelled"==e.message||(console.error(e),Ut(t.id,e.message,e.link))}finally{n.url&&URL.revokeObjectURL(n.url)}}(a,t,t.incognito,e));return{}}(e,t.tab);if(e.method.endsWith(".disableGDrive")){const e=await E();return M(),await Ja.revokeAuthToken(e&&(e.accessToken||e.revokableAccessToken)),{}}if(e.method.endsWith(".end")){if(e.hash)try{await Ta(e.hash,e.woleetKey)}catch(e){Ut(t.tab.id,e.message,e.link)}return wa(e.taskId),{}}return e.method.endsWith(".getInfo")?oa.map(va):e.method.endsWith(".cancel")?(a=e.taskId,ya(oa.find((e=>e.id==a))),{}):e.method.endsWith(".cancelAll")?(Array.from(oa).forEach(ya),{}):e.method.endsWith(".saveUrls")?(la(e.urls),{}):void 0;var a}async function Ka(e,t){let a=await E();const n={interactive:!0,auto:e.extractAuthCode,forceWebAuthFlow:e.forceWebAuthFlow,requestPermissionIdentity:Ha,launchWebAuthFlow:e=>async function(e){const t=await browser.tabs.create({url:e.url,active:!0});return new Promise(((e,a)=>{browser.tabs.onRemoved.addListener((function e(n){n==t.id&&(browser.tabs.onRemoved.removeListener(e),a(new Error("code_required")))}))}))}(e),extractAuthCode:e=>function(e){return new Promise(((t,a)=>{let n;function r(a,s){s&&s.url==e&&(n=a),n==a&&s&&s.title&&s.title.startsWith("Success code=")&&(browser.tabs.onUpdated.removeListener(r),browser.tabs.onUpdated.removeListener(o),t(s.title.substring(13,s.title.length-49)))}function o(e){e==n&&(browser.tabs.onUpdated.removeListener(r),browser.tabs.onUpdated.removeListener(o),a())}browser.tabs.onUpdated.addListener(r),browser.tabs.onRemoved.addListener(o)}))}(e),promptAuthCode:()=>async function(e){const t=await browser.tabs.query({currentWindow:!0,active:!0});return new Promise(((a,n)=>{const r=t[0].id;browser.tabs.onRemoved.addListener((function e(t){t==r&&(J.delete(t),browser.tabs.onUpdated.removeListener(e),n())})),J.set(r,{resolve:a,reject:n}),browser.tabs.sendMessage(r,{method:"common.promptValueRequest",promptMessage:e})}))}("Please enter the access code for Google Drive")};return Ja.setAuthInfo(a,n),a&&a.accessToken&&!t||(a=await Ja.auth(n),a?await P(a):await M()),a}async function $a(e,t,a,n,r,o,s){const i=ga(e);if(!i||!i.cancelled){const i=ja(n,r,o,s,t,a);pa(e,i.cancelPush);try{return await(await i).pushPromise,i}catch(e){throw new Error(e.message+" (GitHub)")}}}async function Xa(e,t,a,n,r){try{await Ka(n);const o=ga(e);if(!o||!o.cancelled){const n=await Ja.upload(t,a,r);return pa(e,n.cancelUpload),n}}catch(o){if("invalid_token"!=o.message)throw new Error(o.message+" (Google Drive)");{let o;try{o=await Ja.refreshAuthToken()}catch(e){if("unknown_token"!=e.message)throw new Error(e.message+" (Google Drive)");o=await Ka(n,!0)}o?await P(o):await M(),await Xa(e,t,a,n,r)}}}async function Ya(t,a){let n;if("skip"==a.filenameConflictAction){(await browser.downloads.search({filenameRegex:"(\\\\|/)"+(r=t.filename,r.replace(Fa,"\\$1")+"$"),exists:!0})).length?n=!0:a.filenameConflictAction="uniquify"}var r;if(!n){const n={url:t.url,saveAs:a.confirmFilename,filename:t.filename,conflictAction:a.filenameConflictAction};a.incognito&&(n.incognito=!0);const r=await e(n,a.filenameReplacementCharacter);r.filename&&t.bookmarkId&&t.replaceBookmarkURL&&(r.filename.startsWith("file:")||(r.filename.startsWith("/")&&(r.filename=r.filename.substring(1)),r.filename="file:///"+r.filename.replace(/#/g,"%23")),await async function(e,t){try{await browser.bookmarks.update(e,t)}catch(e){}}(t.bookmarkId,{url:r.filename}))}}const Za={},Va={};async function Qa(e,t){if("enableAutoSave"==e.method){const a=await s(t.id);a[t.id].autoSave=e.enabled,await i(a),async function(e){Promise.all([kt(e),we(e)])}(t)}if("isAutoSaveEnabled"==e.method)return W(t)}async function en(e,t){const a=t.id,n=await x(t.url,!0);if(n){let r;Ct(a,1,!0),n.content=e.content,n.url=e.url,n.frames=e.frames,n.canvases=e.canvases,n.fonts=e.fonts,n.stylesheets=e.stylesheets,n.images=e.images,n.posters=e.posters,n.usedFonts=e.usedFonts,n.shadowRoots=e.shadowRoots,n.imports=e.imports,n.referrer=e.referrer,n.updatedResources=e.updatedResources,n.visitDate=new Date(e.visitDate),n.backgroundTab=!0,n.autoSave=!0,n.incognito=t.incognito,n.tabId=a,n.tabIndex=t.index;try{if(n.autoSaveExternalSave)await async function(e){e.autoSaveExternalSave=!1;const t=browser.runtime.connectNative("singlefile_companion");t.postMessage({method:"externalSave",pageData:e}),await new Promise(((e,a)=>{t.onDisconnect.addListener((()=>{t.error?a(new Error(t.error.message+" (Companion)")):browser.runtime.lastError&&!browser.runtime.lastError.message.includes("Native host has exited")||e()}))}))}(n);else{if(r=await function(e,t,a,n={fetch:Kt,frameFetch:$t}){return globalThis.singlefile.getPageData(e,n,t,a)}(n,null,null,{fetch:tn}),n.includeInfobar&&await infobar.includeScript(r),n.saveToGDrive){const t=new Blob([r.content],{type:"text/html"});await(await Xa(e.taskId,r.filename,t,n,{})).uploadPromise}else if(n.saveToGitHub)await(await $a(e.taskId,r.filename,r.content,n.githubToken,n.githubUser,n.githubRepository,n.githubBranch)).pushPromise;else if(n.saveWithCompanion)await ka({filename:r.filename,content:r.content,filenameConflictAction:r.filenameConflictAction});else{const e=new Blob([r.content],{type:"text/html"});if(r.url=URL.createObjectURL(e),await Ya(r,n),n.openSavedPage){const n={active:!0,url:URL.createObjectURL(e),windowId:t.windowId},r=t.index;try{await browser.tabs.get(a),n.index=r+1}catch(e){n.index=r}browser.tabs.create(n)}}r.hash&&await Ta(r.hash,n.woleetKey)}}finally{e.taskId?wa(e.taskId):n.autoClose&&(browser.tabs.remove(Va[a]||a),delete Va[a]),r&&r.url&&URL.revokeObjectURL(r.url),_t(a,!0)}}}function tn(e,t={}){return new Promise(((a,n)=>{const r=new XMLHttpRequest;if(r.withCredentials=!0,r.responseType="arraybuffer",r.onerror=e=>n(new Error(e.detail)),r.onreadystatechange=()=>{r.readyState==XMLHttpRequest.DONE&&a({status:r.status,headers:{get:e=>r.getResponseHeader(e)},arrayBuffer:async()=>r.response})},r.open("GET",e,!0),t.headers)for(const e of Object.entries(t.headers))r.setRequestHeader(e[0],e[1]);r.send()}))}async function an(e,t){if(e.method.endsWith(".init")&&(await async function(e,t){await r(e.id);const a=await s(e.id);a[e.id].savedPageDetected=t.savedPageDetected,await i(a)}(t.tab,e),xt(t.tab),function(e){ba(e.id)}(t.tab),async function(e){const[t,a]=await Promise.all([x(e.url,!0),W(e)]);t&&(t.autoSaveLoad||t.autoSaveLoadOrUnload)&&a&&da([e],{autoSave:!0})}(t.tab)),e.method.endsWith(".promptValueResponse")&&async function(e,t){const a=J.get(t.tab.id);a&&(a.resolve(e.value),J.delete(t.tab.id))}(e,t),e.method.endsWith(".getOptions"))return x(e.url);e.method.endsWith(".activate")&&await browser.tabs.update(e.tabId,{active:!0})}browser.tabs.onCreated.addListener((e=>function(e){!function(e){xt(e)}(e)}(e))),browser.tabs.onActivated.addListener((e=>async function(e){Ot(await browser.tabs.get(e.tabId))}(e))),browser.tabs.onRemoved.addListener((e=>function(e){r(e),function(e){R.delete(e)}(e),ba(e),async function(e){const t=Za[e];t?t.autoSaveRemove&&(delete Za[e],await en(t,t.tab)):Za[e]={removed:!0}}(e)}(e))),browser.tabs.onUpdated.addListener(((e,t)=>async function(e,t){if("complete"==t.status){setTimeout((async()=>{try{await browser.tabs.sendMessage(e,{method:"content.maybeInit"})}catch(e){}}),1500),function(e){delete Za[e]}(e);const t=await browser.tabs.get(e);if(B(t)){const e=await s(t.id);e[t.id].editorDetected=!0,await i(e),Ot(t)}}t.discarded&&async function(e){const t=Za[e];t?(delete Za[e],await en(t,t.tab)):Za[e]={discarded:!0}}(e)}(e,t))),browser.tabs.onReplaced.addListener(((e,t)=>function(e,t){!async function(e,t){Za[t]&&!Za[e]&&(Za[e]=Za[t],delete Za[t],Va[t]=e);const a=await s();a[t]&&!a[e]&&(a[e]=a[t],delete a[t],await i(a))}(e,t)}(e,t))),browser.runtime.onMessage.addListener(((e,t)=>{if("singlefile.frameTree.initResponse"==e.method||"singlefile.frameTree.ackInitRequest"==e.method)return browser.tabs.sendMessage(t.tab.id,e,{frameId:0}),Promise.resolve({})}));const nn=new Map;function rn(e,t){e.delete(t)}browser.runtime.onMessage.addListener(((e,t)=>{if("singlefile.lazyTimeout.setTimeout"==e.method){let a,n=nn.get(t.tab.id);if(n)if(a=n.get(t.frameId),a){const t=a.get(e.type);t&&clearTimeout(t)}else a=new Map;const r=setTimeout((async()=>{try{const a=nn.get(t.tab.id),n=a.get(t.frameId);a&&n&&rn(n,e.type),await browser.tabs.sendMessage(t.tab.id,{method:"singlefile.lazyTimeout.onTimeout",type:e.type})}catch(e){}}),e.delay);return n||(n=new Map,a=new Map,n.set(t.frameId,a),nn.set(t.tab.id,n)),a.set(e.type,r),Promise.resolve({})}if("singlefile.lazyTimeout.clearTimeout"==e.method){let a=nn.get(t.tab.id);if(a){const n=a.get(t.frameId);if(n){const t=n.get(e.type);t&&clearTimeout(t),rn(n,e.type)}}return Promise.resolve({})}})),browser.tabs.onRemoved.addListener((e=>nn.delete(e))),browser.runtime.onMessage.addListener(((e,t)=>e.method.startsWith("tabs.")?an(e,t):e.method.startsWith("downloads.")?Ga(e,t):e.method.startsWith("autosave.")?async function(e,t){if(e.method.endsWith(".save"))return e.autoSaveDiscard||e.autoSaveRemove?(t.tab?(e.tab=t.tab,Za[t.tab.id]=e):Za[e.tabId]&&(Za[e.tabId].removed&&e.autoSaveRemove||Za[e.tabId].discarded&&e.autoSaveDiscard)&&(delete Za[e.tabId],await en(e,{id:e.tabId,index:e.tabIndex,url:t.url})),e.autoSaveUnload&&(delete Za[e.tabId],await en(e,t.tab))):(delete Za[e.tabId],await en(e,t.tab)),{}}(e,t):e.method.startsWith("ui.")?Lt(e,t):e.method.startsWith("config.")?k(e):e.method.startsWith("tabsData.")?function(e){return e.method.endsWith(".get")?s():e.method.endsWith(".set")?i(e.tabsData):void 0}(e):e.method.startsWith("devtools.")?async function(e){e.method.endsWith(".resourceCommitted")&&e.tabId&&e.url&&("stylesheet"==e.type||"script"==e.type)&&await browser.tabs.sendMessage(e.tabId,e)}(e):e.method.startsWith("editor.")?async function(e,t){if(e.method.endsWith(".getTabData")){const e=t.tab,a=R.get(e.id);if(a){const t=await x(a.url),n=JSON.stringify(a);for(let a=0;a*AA,r.truncated?(r.finished=(a+1)*A>n.length,r.content=n.substring(a*A,(a+1)*A)):(r.content=n,r.options=t),await browser.tabs.sendMessage(e.id,r)}}}if(e.method.endsWith(".open")){let a;const n=t.tab;if(e.truncated?(a=C.get(n.id),a||(a=[],C.set(n.id,a)),a.push(e.content),e.finished&&C.delete(n.id)):e.content&&(a=[e.content]),!e.truncated||e.finished){const t={url:L};await browser.tabs.update(n.id,t),R.set(n.id,{url:n.url,content:a.join(""),filename:e.filename})}}}(e,t):e.method.startsWith("bookmarks.")?Ia(e):e.method.startsWith("companion.")?async function(e){if(e.method.endsWith(".state"))return{enabled:!0}}(e):e.method.startsWith("requests.")?F(e):e.method.startsWith("bootstrap.")?async function(e,t){if(e.method.endsWith(".init")){const[e,a]=await Promise.all([x(t.tab.url,!0),W(t.tab)]);return{options:e,autoSaveEnabled:a,tabId:t.tab.id,tabIndex:t.tab.index}}}(e,t):void 0)),browser.runtime.onMessageExternal&&browser.runtime.onMessageExternal.addListener((async(e,t)=>{const a=(await browser.tabs.query({currentWindow:!0,active:!0}))[0];return!!a&&Qa(e,a)}))}(); diff --git a/dist/extension-core.js b/dist/extension-core.js deleted file mode 100644 index dca8cf4ca..000000000 --- a/dist/extension-core.js +++ /dev/null @@ -1 +0,0 @@ -!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).extension={})}(this,(function(e){"use strict";let r,t;const a=["dist/chrome-browser-polyfill.js","dist/single-file.js"],s=["dist/chrome-browser-polyfill.js","dist/single-file-frames.js"];async function n(e,n){let o;if(await async function(e){const n=e.extensionScriptFiles||[];r||t||([r,t]=await Promise.all([i(a.concat(n)),i(s)]))}(n),!n.removeFrames)try{await browser.tabs.executeScript(e,{code:t,allFrames:!0,matchAboutBlank:!0,runAt:"document_start"})}catch(e){}try{await browser.tabs.executeScript(e,{code:r,allFrames:!1,runAt:"document_idle"}),o=!0}catch(e){}return o&&n.frameId&&await browser.tabs.executeScript(e,{code:"document.documentElement.dataset.requestedFrameId = true",frameId:n.frameId,matchAboutBlank:!0,runAt:"document_start"}),o}async function i(e){const r=e.map((async e=>{if("function"==typeof e)return"("+e.toString()+")();";{const r=await fetch(browser.runtime.getURL("../../../"+e));return(new TextDecoder).decode(await r.arrayBuffer())}}));let t="";for(const e of r)t+=await e;return t}const o="single-file-response-fetch",c=(e,r)=>window.fetch(e,r);let d=0,u=new Map;async function f(e,r={}){try{let t=await c(e,{cache:"force-cache",headers:r.headers});return 401!=t.status&&403!=t.status&&404!=t.status||(t=await w(e)),t}catch(t){d++;const a=new Promise(((e,r)=>u.set(d,{resolve:e,reject:r})));return await h({method:"singlefile.fetch",url:e,requestId:d,referrer:r.referrer,headers:r.headers}),a}}async function l(e,r){const t=await h({method:"singlefile.fetchFrame",url:e,frameId:r.frameId,referrer:r.referrer,headers:r.headers});return{status:t.status,headers:new Map(t.headers),arrayBuffer:async()=>new Uint8Array(t.array).buffer}}async function h(e){const r=await browser.runtime.sendMessage(e);if(!r||r.error)throw new Error(r&&r.error&&r.error.toString());return r}function w(e){return new Promise(((r,t)=>{var a,s,n,i;a=new CustomEvent("single-file-request-fetch",{detail:e}),window.dispatchEvent(a),s=o,n=function a(s){var n,i,c;s.detail?s.detail.url==e&&(n=o,i=a,c=!1,window.removeEventListener(n,i,c),s.detail.response?r({status:s.detail.status,headers:new Map(s.detail.headers),arrayBuffer:async()=>s.detail.response}):t(s.detail.error)):t()},i=!1,window.addEventListener(s,n,i)}))}browser.runtime.onMessage.addListener((e=>"singlefile.fetchFrame"==e.method&&window.frameId&&window.frameId==e.frameId?async function(e){try{let r=await c(e.url,{cache:"force-cache",headers:e.headers});return 401!=r.status&&403!=r.status&&404!=r.status||(r=await Promise.race([w(e.url),new Promise(((e,r)=>setTimeout((()=>r()),5e3)))])),{status:r.status,headers:[...r.headers],array:Array.from(new Uint8Array(await r.arrayBuffer()))}}catch(e){return{error:e&&e.toString()}}}(e):"singlefile.fetchResponse"==e.method?async function(e){const r=u.get(e.requestId);r&&(e.error?(r.reject(new Error(e.error)),u.delete(e.requestId)):(e.truncated&&(r.array?r.array=r.array.concat(e.array):(r.array=e.array,u.set(e.requestId,r)),e.finished&&(e.array=r.array)),e.truncated&&!e.finished||(r.resolve({status:e.status,headers:{get:r=>e.headers&&e.headers[r]},arrayBuffer:async()=>new Uint8Array(e.array).buffer}),u.delete(e.requestId))));return{}}(e):void 0)),e.getPageData=function(e,r,t,a={fetch:f,frameFetch:l}){return globalThis.singlefile.getPageData(e,a,r,t)},e.injectScript=function(e,r){return n(e,r)},Object.defineProperty(e,"__esModule",{value:!0})})); diff --git a/dist/infobar.js b/dist/infobar.js deleted file mode 100644 index abefc6530..000000000 --- a/dist/infobar.js +++ /dev/null @@ -1 +0,0 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).infobar={})}(this,(function(e){"use strict";const t="/dist/web/infobar-web.js",n=globalThis.browser;e.includeScript=async function(e){let i,o;for(n&&n.runtime&&n.runtime.getURL?i=await(await fetch(n.runtime.getURL(t))).text():singlefile.getFileContent&&(i=singlefile.getFileContent(t));o!=i;)o=i,i=i.replace(/\/\*(.|\n)*?\*\//,"");i=i.replace(/\t+/g," ").replace(/\nthis\.[^(]*/gi,"\n").replace(/\n+/g,""),e.content+=" - - - - - - \ No newline at end of file diff --git a/extension/lib/woleet/woleet.js b/extension/lib/woleet/woleet.js deleted file mode 100644 index ead792d9b..000000000 --- a/extension/lib/woleet/woleet.js +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2010-2020 Gildas Lormeau - * contact : gildas.lormeau gmail.com - * - * This file is part of SingleFile. - * - * The code in this file is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * (GNU AGPL) as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * The code in this file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero - * General Public License for more details. - * - * As additional permission under GNU AGPL version 3 section 7, you may - * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU - * AGPL normally required by section 4, provided you include this license - * notice and a URL through which recipients can access the Corresponding - * Source. - */ -/* global fetch */ -const urlService = "https://api.woleet.io/v1/anchor"; -const apiKey = ""; -export { - anchor -}; -async function anchor(hash, userKey) { - let bearer = userKey || apiKey; - const response = await fetch(urlService, { - method: "POST", - headers: { - "Accept": "application/json", - "Content-Type": "application/json", - "Authorization": "Bearer " + bearer - }, - body: JSON.stringify({ - "name": hash, - "hash": hash, - "public": true - }) - }); - if (response.status == 401) { - const error = new Error("Your access token on Woleet is invalid. Go to __DOC_LINK__ to create your account."); - error.link = "https://app.woleet.io/"; - throw error; - } else if (response.status == 402) { - const error = new Error("You have no more credits on Woleet. Go to __DOC_LINK__ to recharge them."); - error.link = "https://app.woleet.io/"; - throw error; - } else if (response.status >= 400) { - throw new Error((response.statusText || ("Error " + response.status)) + " (Woleet)"); - } - return response.json(); -} \ No newline at end of file diff --git a/extension/ui/pages/editor.html b/extension/ui/pages/editor.html deleted file mode 100644 index 86e0ce573..000000000 --- a/extension/ui/pages/editor.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - -   - - - -
-
- - - - - -
-
-
- - - - - - -
-
-
- - -
-
-
- - - - - -
-
-
- - -
-
- - - - - - - - \ No newline at end of file diff --git a/dist/chrome-browser-polyfill.js b/lib/chrome-browser-polyfill.js similarity index 100% rename from dist/chrome-browser-polyfill.js rename to lib/chrome-browser-polyfill.js diff --git a/lib/extension-background.js b/lib/extension-background.js new file mode 100644 index 000000000..77e5951e8 --- /dev/null +++ b/lib/extension-background.js @@ -0,0 +1 @@ +!function(){"use strict";async function e(t,a){let n;try{n=await browser.downloads.download(t)}catch(n){if(n.message){const r=n.message.toLowerCase(),o=r.includes("illegal characters")||r.includes("invalid filename");if(o&&t.filename.startsWith("."))return t.filename=a+t.filename,e(t,a);if(o&&t.filename.includes(","))return t.filename=t.filename.replace(/,/g,a),e(t,a);if(o&&!t.filename.match(/^[\x00-\x7F]+$/))return t.filename=t.filename.replace(/[^\x00-\x7F]+/g,a),e(t,a);if((r.includes("'incognito'")||r.includes('"incognito"'))&&t.incognito)return delete t.incognito,e(t,a);if("conflictaction prompt not yet implemented"==r&&t.conflictAction)return delete t.conflictAction,e(t,a);if(r.includes("canceled"))return{};throw n}throw n}return new Promise(((e,t)=>{browser.downloads.onChanged.addListener((function a(r){r.id==n&&r.state&&("complete"==r.state.current&&(browser.downloads.search({id:n}).then((t=>e({filename:t[0]&&t[0].filename}))).catch((()=>e({}))),browser.downloads.onChanged.removeListener(a)),"interrupted"==r.state.current&&(r.error&&"USER_CANCELED"==r.error.current?e({}):t(new Error(r.state.current)),browser.downloads.onChanged.removeListener(a)))}))}))}let t,a,n;async function r(e){a&&delete a[e];const t=await s();if(t[e]){const a=t[e].autoSave;t[e]={autoSave:a},await i(t)}}function o(e){return a||(a={}),void 0===e||a[e]||(a[e]={}),a}async function s(e){if(!t){const e=await browser.storage.local.get();t=e.tabsData||{}}return async function(){if(!n){n=!0;const e=await browser.tabs.query({currentWindow:!0,highlighted:!0});Object.keys(t).filter((t=>{if("autoSaveAll"!=t&&"autoSaveUnpinned"!=t&&"profileName"!=t)return!e.find((e=>e.id==t))})).forEach((e=>delete t[e])),await browser.storage.local.set({tabsData:t})}}(),void 0===e||t[e]||(t[e]={}),t}async function i(e){t=e,await browser.storage.local.set({tabsData:e})}setTimeout((()=>s().then((e=>t=e))),0);const c="-",l="__Default_Settings__",d="__Disabled_Settings__",u="regexp:",f={removeHiddenElements:!0,removeUnusedStyles:!0,removeUnusedFonts:!0,removeFrames:!1,removeImports:!0,removeScripts:!0,compressHTML:!0,compressCSS:!1,loadDeferredImages:!0,loadDeferredImagesMaxIdleTime:1500,loadDeferredImagesBlockCookies:!1,loadDeferredImagesBlockStorage:!1,loadDeferredImagesKeepZoomLevel:!1,filenameTemplate:"{page-title} ({date-locale} {time-locale}).html",infobarTemplate:"",includeInfobar:!1,confirmInfobarContent:!1,autoClose:!1,confirmFilename:!1,filenameConflictAction:"uniquify",filenameMaxLength:192,filenameMaxLengthUnit:"bytes",filenameReplacedCharacters:["~","+","\\\\","?","%","*",":","|",'"',"<",">","\0-",""],filenameReplacementCharacter:"_",contextMenuEnabled:!0,tabMenuEnabled:!0,browserActionMenuEnabled:!0,shadowEnabled:!0,logsEnabled:!0,progressBarEnabled:!0,maxResourceSizeEnabled:!1,maxResourceSize:10,removeAudioSrc:!0,removeVideoSrc:!0,displayInfobar:!0,displayStats:!1,backgroundSave:!/Mobile.*Firefox/.test(navigator.userAgent),defaultEditorMode:"normal",applySystemTheme:!0,autoSaveDelay:1,autoSaveLoad:!1,autoSaveUnload:!1,autoSaveLoadOrUnload:!0,autoSaveDiscard:!1,autoSaveRemove:!1,autoSaveRepeat:!1,autoSaveRepeatDelay:10,removeAlternativeFonts:!0,removeAlternativeMedias:!0,removeAlternativeImages:!0,groupDuplicateImages:!0,saveRawPage:!1,saveToClipboard:!1,addProof:!1,saveToGDrive:!1,saveToGitHub:!1,githubToken:"",githubUser:"",githubRepository:"SingleFile-Archives",githubBranch:"main",saveWithCompanion:!1,forceWebAuthFlow:!1,extractAuthCode:!0,resolveFragmentIdentifierURLs:!1,userScriptEnabled:!1,openEditor:!1,openSavedPage:!1,autoOpenEditor:!1,saveCreatedBookmarks:!1,allowedBookmarkFolders:[],ignoredBookmarkFolders:[],replaceBookmarkURL:!0,saveFavicon:!0,includeBOM:!1,warnUnsavedPage:!0,autoSaveExternalSave:!1,insertMetaNoIndex:!1,insertMetaCSP:!0,passReferrerOnError:!1,insertSingleFileComment:!0,blockMixedContent:!1,saveOriginalURLs:!1,acceptHeaders:{font:"application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8",image:"image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8",stylesheet:"text/css,*/*;q=0.1",script:"*/*",document:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},moveStylesInHead:!1,woleetKey:""};let h,m=w();async function w(){const{sync:e}=await browser.storage.local.get();h=e?browser.storage.sync:browser.storage.local;const t=await h.get();if(t.profiles)t.rules||(t.rules=[]),Object.keys(t.profiles).forEach((e=>p(t.profiles[e]))),await h.remove(["profiles","defaultProfile","rules"]),await h.set({profiles:t.profiles,rules:t.rules});else{const e=t;delete e.tabsData,p(e);const a={profiles:{},rules:[]};a.profiles.__Default_Settings__=e,h.remove(Object.keys(f)),await h.set(a)}t.maxParallelWorkers||await h.set({maxParallelWorkers:navigator.hardwareConcurrency||4})}function p(e){Object.keys(f).forEach((t=>function(e,t){void 0===e[t]&&(e[t]=f[t])}(e,t)))}async function b(e,t){const a=await g(),n=a.rules.filter((e=>v(e)));let r=n.sort(y).find((t=>e&&e.match(new RegExp(t.url.split(u)[1]))));if(!r){const n=a.rules.filter((e=>!v(e)));r=n.sort(y).find((a=>!t&&"*"==a.url||e&&e.includes(a.url)))}return r}async function g(){return await m,h.get(["profiles","rules","maxParallelWorkers"])}function y(e,t){return t.url.length-e.url.length}function v(e){return e.url.toLowerCase().startsWith(u)}async function k(t){if(t.method.endsWith(".deleteRules")&&await async function(e){const t=await g();t.rules=t.rules=e?t.rules.filter((t=>t.autoSaveProfile!=e&&t.profile!=e)):[],await h.set({rules:t.rules})}(t.profileName),t.method.endsWith(".deleteRule")&&await async function(e){if(!e)throw new Error("URL is empty");const t=await g();t.rules=t.rules.filter((t=>t.url!=e)),await h.set({rules:t.rules})}(t.url),t.method.endsWith(".addRule")&&await S(t.url,t.profileName,t.autoSaveProfileName),t.method.endsWith(".createProfile")&&await async function(e,t){const a=await g();if(Object.keys(a.profiles).includes(e))throw new Error("Duplicate profile name");a.profiles[e]=JSON.parse(JSON.stringify(a.profiles[t])),await h.set({profiles:a.profiles})}(t.profileName,t.fromProfileName||l),t.method.endsWith(".renameProfile")&&await async function(e,t){const[a,n]=await Promise.all([g(),s()]);if(!Object.keys(a.profiles).includes(e))throw new Error("Profile not found");if(Object.keys(a.profiles).includes(t))throw new Error("Duplicate profile name");if(e==l)throw new Error("Default settings cannot be renamed");n.profileName==e&&(n.profileName=t,await i(n));a.profiles[t]=a.profiles[e],a.rules.forEach((a=>{a.profile==e&&(a.profile=t),a.autoSaveProfile==e&&(a.autoSaveProfile=t)})),delete a.profiles[e],await h.set({profiles:a.profiles,rules:a.rules})}(t.profileName,t.newProfileName),t.method.endsWith(".deleteProfile")&&await async function(e){const[t,a]=await Promise.all([g(),s()]);if(!Object.keys(t.profiles).includes(e))throw new Error("Profile not found");if(e==l)throw new Error("Default settings cannot be deleted");a.profileName==e&&(delete a.profileName,await i(a));t.rules.forEach((t=>{t.profile==e&&(t.profile=l),t.autoSaveProfile==e&&(t.autoSaveProfile=l)})),delete t.profiles[e],await h.set({profiles:t.profiles,rules:t.rules})}(t.profileName),t.method.endsWith(".resetProfiles")&&await async function(){await m;const e=await s();delete e.profileName,await i(e),await h.remove(["profiles","rules","maxParallelWorkers"]),await browser.storage.local.set({sync:!1}),h=browser.storage.local,await w()}(),t.method.endsWith(".resetProfile")&&await async function(e){const t=await g();if(!Object.keys(t.profiles).includes(e))throw new Error("Profile not found");t.profiles[e]=f,await h.set({profiles:t.profiles})}(t.profileName),t.method.endsWith(".importConfig")&&await async function(e){await h.remove(["profiles","rules","maxParallelWorkers"]),await h.set({profiles:e.profiles,rules:e.rules,maxParallelWorkers:e.maxParallelWorkers}),await w()}(t.config),t.method.endsWith(".updateProfile")&&await async function(e,t){const a=await g();if(!Object.keys(a.profiles).includes(e))throw new Error("Profile not found");Object.keys(t).forEach((n=>a.profiles[e][n]=t[n])),await h.set({profiles:a.profiles})}(t.profileName,t.profile),t.method.endsWith(".updateRule")&&await T(t.url,t.newUrl,t.profileName,t.autoSaveProfileName),t.method.endsWith(".getConstants"))return{DISABLED_PROFILE_NAME:d,DEFAULT_PROFILE_NAME:l,CURRENT_PROFILE_NAME:c};if(t.method.endsWith(".getRules"))return async function(){return(await g()).rules}();if(t.method.endsWith(".getProfiles"))return I();if(t.method.endsWith(".exportConfig"))return async function(){const t=await g(),a=URL.createObjectURL(new Blob([JSON.stringify({profiles:t.profiles,rules:t.rules,maxParallelWorkers:t.maxParallelWorkers},null,2)],{type:"text/json"})),n={url:a,filename:`singlefile-settings-${(new Date).toISOString().replace(/:/g,"_")}.json`,saveAs:!0};try{await e(n,"_")}finally{URL.revokeObjectURL(a)}}();if(t.method.endsWith(".enableSync")){await browser.storage.local.set({sync:!0});const e=await browser.storage.sync.get();if(!e||!e.profiles){const e=await browser.storage.local.get();await browser.storage.sync.set({profiles:e.profiles,rules:e.rules,maxParallelWorkers:e.maxParallelWorkers})}return h=browser.storage.sync,{}}if(t.method.endsWith(".disableSync")){await browser.storage.local.set({sync:!1});const e=await browser.storage.sync.get();e&&e.profiles&&await browser.storage.local.set({profiles:e.profiles,rules:e.rules,maxParallelWorkers:e.maxParallelWorkers}),h=browser.storage.local}return t.method.endsWith(".isSync")?{sync:(await browser.storage.local.get()).sync}:{}}async function I(){return(await g()).profiles}async function x(e,t){const[a,n,r]=await Promise.all([g(),b(e),s()]),o=r.profileName||l;let i;if(n){const e=n[t?"autoSaveProfile":"profile"];i=e==c?o:e}else i=o;return Object.assign({profileName:i},a.profiles[i])}async function S(e,t,a){if(!e)throw new Error("URL is empty");const n=await g();if(n.rules.find((t=>t.url==e)))throw new Error("URL already exists");n.rules.push({url:e,profile:t,autoSaveProfile:a}),await h.set({rules:n.rules})}async function T(e,t,a,n){if(!e||!t)throw new Error("URL is empty");const r=await g(),o=r.rules.find((t=>t.url==e));if(!o)throw new Error("URL not found");if(r.rules.find((a=>a.url==t&&a.url!=e)))throw new Error("New URL already exists");o.url=t,o.profile=a,o.autoSaveProfile=n,await h.set({rules:r.rules})}async function E(){return(await h.get()).authInfo}async function P(e){await h.set({authInfo:e})}async function M(){let e=E();e.revokableAccessToken?P({revokableAccessToken:e.revokableAccessToken}):await h.remove(["authInfo"])}async function W(e){if(e){const[t,a]=await Promise.all([s(),b(e.url)]);return Boolean(t.autoSaveAll||t.autoSaveUnpinned&&!e.pinned||t[e.id]&&t[e.id].autoSave)&&(!a||a.autoSaveProfile!=d)}}const A=33554432,L="/src/extension/ui/pages/editor.html",R=new Map,C=new Map,U=browser.runtime.getURL(L);function B(e){return e.url==U}const _=new Map,D="x-single-file-request-id",O=8388608;async function j(e,t,a){for(let n=0;n*OO,r.truncated?(r.finished=(n+1)*O>a.array.length,r.array=a.array.slice(n*O,(n+1)*O)):r.array=a.array,await browser.tabs.sendMessage(e,r)}return{}}function N(e,t={},a){return new Promise(((n,r)=>{const o=new XMLHttpRequest;if(o.withCredentials=!0,o.responseType="arraybuffer",o.onerror=e=>r(new Error(e.detail)),o.onreadystatechange=()=>{o.readyState==XMLHttpRequest.DONE&&(o.status||o.response.byteLength?401!=o.status&&403!=o.status&&404!=o.status||a?n({array:Array.from(new Uint8Array(o.response)),headers:{"content-type":o.getResponseHeader("Content-Type")},status:o.status}):N(e,t,!0).then(n).catch(r):r())},o.open("GET",e,!0),t.headers)for(const e of Object.entries(t.headers))o.setRequestHeader(e[0],e[1]);if(a){const e=String(Math.random()).substring(2);!function(e,t){_.set(e,t)}(e,t.referrer),o.setRequestHeader(D,e)}o.send()}))}browser.runtime.onMessage.addListener(((e,t)=>{if(e.method&&e.method.startsWith("singlefile.fetch"))return new Promise((a=>{(async function(e,t){if("singlefile.fetch"==e.method)try{const a=await N(e.url,{referrer:e.referrer,headers:e.headers});return j(t.tab.id,e.requestId,a)}catch(a){return j(t.tab.id,e.requestId,{error:a.message,arrray:[]})}else if("singlefile.fetchFrame"==e.method)return browser.tabs.sendMessage(t.tab.id,e)})(e,t).then(a).catch((e=>a({error:e&&e.toString()})))}))}));let q=!1;function F(e){return e.method.endsWith(".enableReferrerOnError")?(H(),{}):e.method.endsWith(".disableReferrerOnError")?(function(){try{browser.webRequest.onBeforeSendHeaders.removeListener(z)}catch(e){}q=!1}(),{}):void 0}function z(e){if(q){let t=e.requestHeaders.find((e=>e.name===D));if(t){e.requestHeaders=e.requestHeaders.filter((e=>e.name!==D));const a=_.get(t.value);if(a){_.delete(t.value);if(!e.requestHeaders.find((e=>"referer"===e.name.toLowerCase())))return e.requestHeaders.push({name:"Referer",value:a}),{requestHeaders:e.requestHeaders}}}}}function H(){if(!q){try{browser.webRequest.onBeforeSendHeaders.addListener(z,{urls:[""]},["blocking","requestHeaders","extraHeaders"])}catch(e){browser.webRequest.onBeforeSendHeaders.addListener(z,{urls:[""]},["blocking","requestHeaders"])}q=!0}}const J=new Map;async function G(e){return(await browser.tabs.query(e)).sort(((e,t)=>e.index-t.index))}const K="/src/extension/ui/resources/icon_128.png",$="/src/extension/ui/resources/icon_128_wait",X=browser.i18n.getMessage("buttonDefaultTooltip"),Y=browser.i18n.getMessage("buttonBlockedTooltip"),Z=browser.i18n.getMessage("buttonInitializingBadge"),V=browser.i18n.getMessage("buttonInitializingTooltip"),Q=browser.i18n.getMessage("buttonErrorBadge"),ee=browser.i18n.getMessage("buttonBlockedBadge"),te=browser.i18n.getMessage("buttonOKBadge"),ae=browser.i18n.getMessage("buttonSaveProgressTooltip"),ne=browser.i18n.getMessage("buttonUploadProgressTooltip"),re=browser.i18n.getMessage("buttonAutoSaveActiveBadge"),oe=browser.i18n.getMessage("buttonAutoSaveActiveTooltip"),se=[2,147,20,192],ie=[4,229,36,192],ce={default:{setBadgeBackgroundColor:{color:se},setBadgeText:{text:""},setTitle:{title:X},setIcon:{path:K}},inject:{setBadgeBackgroundColor:{color:se},setBadgeText:{text:Z},setTitle:{title:V}},execute:{setBadgeBackgroundColor:{color:ie},setBadgeText:{text:Z}},progress:{setBadgeBackgroundColor:{color:ie},setBadgeText:{text:""}},edit:{setBadgeBackgroundColor:{color:se},setBadgeText:{text:""},setTitle:{title:X},setIcon:{path:K}},end:{setBadgeBackgroundColor:{color:ie},setBadgeText:{text:te},setTitle:{title:X},setIcon:{path:K}},error:{setBadgeBackgroundColor:{color:[229,4,12,192]},setBadgeText:{text:Q},setTitle:{title:""},setIcon:{path:K}},forbidden:{setBadgeBackgroundColor:{color:[255,255,255,1]},setBadgeText:{text:ee},setTitle:{title:Y},setIcon:{path:K}},autosave:{inject:{setBadgeBackgroundColor:{color:[64,64,64,192]},setBadgeText:{text:re},setTitle:{title:oe},setIcon:{path:K}},default:{setBadgeBackgroundColor:{color:[208,208,208,192]},setBadgeText:{text:re},setTitle:{title:oe},setIcon:{path:K}}}};let le;function de(e,t){if(e.method.endsWith(".processInit")){delete o(t.tab.id)[t.tab.id].button,we(t.tab)}var a,n,r;return e.method.endsWith(".processProgress")&&e.maxIndex&&(a=t.tab.id,n=e.index,r=e.maxIndex,me(a,n,r,ae)),e.method.endsWith(".processEnd")&&fe(t.tab.id),e.method.endsWith(".processError")&&(e.error&&console.error("Initialization error",e.error),ue(t.tab.id)),e.method.endsWith(".processCancelled")&&he(t.tab),Promise.resolve({})}function ue(e){pe(e,ge("error"))}function fe(e,t){pe(e,t?ge("default",!0):ge("end"))}function he(e){we(e)}function me(e,t,a,n){const r=Math.max(Math.min(20,Math.floor(t/a*20)),0),o=Math.min(Math.floor(t/a*8),8),s=$+o+".png",i=ge("progress");i.setTitle={title:n+5*r+"%"},i.setIcon={path:s},pe(e,i)}async function we(e){const t=ge("default",await W(e));await pe(e.id,t)}async function pe(e,t){const a=o(e);if(t){a[e].button||(a[e].button={lastState:null});const n=a[e].button.lastState||{},r={};Object.keys(t).forEach((e=>{void 0!==t[e]&&JSON.stringify(n[e])!=JSON.stringify(t[e])&&(r[e]=t[e])})),Object.keys(r).length&&(a[e].button.lastState=t,await async function(e,t){for(const a of Object.keys(t))await be(e,a,t[a])}(e,r))}}async function be(e,t,a){if(browser.browserAction[t]){const n=JSON.parse(JSON.stringify(a));n.tabId=e,await browser.browserAction[t](n)}}function ge(e,t){return JSON.parse(JSON.stringify(t?ce.autosave[e]:ce[e]))}browser.browserAction.onClicked.addListener((async e=>{const t=await G({currentWindow:!0,highlighted:!0});t.length<=1?function(e){le.isSavingTab(e)?le.cancelTab(e.id):le.saveTabs([e])}(e):le.saveTabs(t)}));const ye=browser.menus,ve=ye&&ye.onClicked&&ye.create&&ye.update&&ye.removeAll,ke="save-page",Ie="edit-and-save-page",xe="save-with-profile",Se="save-selected-links",Te="view-pendings",Ee="select-profile",Pe="wasve-with-profile-",Me="select-profile-",We="associate-with-profile",Ae="associate-with-profile-",Le="save-selected",Re="save-frame",Ce="save-tabs",Ue="save-selected-tabs",Be="save-unpinned-tabs",_e="save-all-tabs",De="button-save-selected-tabs",Oe="button-save-unpinned-tabs",je="button-save-all-tabs",Ne="auto-save",qe="auto-save-disabled",Fe="auto-save-tab",ze="auto-save-unpinned",He="auto-save-all",Je=browser.i18n.getMessage("menuCreateDomainRule"),Ge=browser.i18n.getMessage("menuUpdateRule"),Ke=browser.i18n.getMessage("menuSavePage"),$e=browser.i18n.getMessage("menuSaveWithProfile"),Xe=browser.i18n.getMessage("menuSaveSelectedLinks"),Ye=browser.i18n.getMessage("menuEditPage"),Ze=browser.i18n.getMessage("menuEditAndSavePage"),Ve=browser.i18n.getMessage("menuViewPendingSaves"),Qe=browser.i18n.getMessage("menuSaveSelection"),et=browser.i18n.getMessage("menuSaveFrame"),tt=browser.i18n.getMessage("menuSaveTabs"),at=browser.i18n.getMessage("menuSaveSelectedTabs"),nt=browser.i18n.getMessage("menuSaveUnpinnedTabs"),rt=browser.i18n.getMessage("menuSaveAllTabs"),ot=browser.i18n.getMessage("menuSelectProfile"),st=browser.i18n.getMessage("profileDefaultSettings"),it=browser.i18n.getMessage("menuAutoSave"),ct=browser.i18n.getMessage("menuAutoSaveDisabled"),lt=browser.i18n.getMessage("menuAutoSaveTab"),dt=browser.i18n.getMessage("menuAutoSaveUnpinnedTabs"),ut=browser.i18n.getMessage("menuAutoSaveAllTabs"),ft=[Ie,Se,Le,Re,Ne,We],ht=new Map,mt=new Map;let wt,pt,bt,gt=!0,yt=!0,vt=new Map;async function kt(e){const[t,a]=await Promise.all([I(),s()]),n=await x(e&&e.url);if(ve&&n){const r=["page","frame","image","link","video","audio","selection"],o=[];if(n.browserActionMenuEnabled&&o.push("browser_action"),n.tabMenuEnabled)try{ye.create({id:"temporary-id",contexts:["tab"],title:"title"}),o.push("tab")}catch(e){n.tabMenuEnabled=!1}await ye.removeAll();const s=o.concat(...r),i=n.contextMenuEnabled?s:o;if(ye.create({id:ke,contexts:i,title:Ke}),ye.create({id:Ie,contexts:i,title:Ze}),ye.create({id:Se,contexts:n.contextMenuEnabled?o.concat(["selection"]):o,title:Xe}),Object.keys(t).length>1&&ye.create({id:xe,contexts:i,title:$e}),n.contextMenuEnabled&&ye.create({id:"separator-1",contexts:r,type:"separator"}),ye.create({id:Le,contexts:i,title:Qe}),n.contextMenuEnabled&&ye.create({id:Re,contexts:["frame"],title:et}),ye.create({id:Ce,contexts:o,title:tt}),ye.create({id:De,contexts:o,title:at,parentId:Ce}),ye.create({id:Oe,contexts:o,title:nt,parentId:Ce}),ye.create({id:je,contexts:o,title:rt,parentId:Ce}),n.contextMenuEnabled&&(ye.create({id:Ue,contexts:r,title:at}),ye.create({id:Be,contexts:r,title:nt}),ye.create({id:_e,contexts:r,title:rt}),ye.create({id:"separator-2",contexts:r,type:"separator"})),Object.keys(t).length>1){ye.create({id:Ee,title:ot,contexts:i}),ye.create({id:"wasve-with-profile-default",contexts:i,title:st,parentId:xe});const o="select-profile-default",s=!a.profileName||a.profileName==l;let d;ye.create({id:o,type:"radio",contexts:i,title:st,checked:s,parentId:Ee}),ht.set(o,s),ye.create({id:We,title:Je,contexts:i}),mt.set(We,Je),e&&e.url&&(d=await b(e.url,!0));const u="associate-with-profile-current",f=!d||d.profile==c;ye.create({id:u,type:"radio",contexts:i,title:c,checked:f,parentId:We}),ht.set(u,f);const h="associate-with-profile-default",m=Boolean(d)&&d.profile==l;ye.create({id:h,type:"radio",contexts:i,title:st,checked:m,parentId:We}),ht.set(h,m),vt=new Map,Object.keys(t).forEach(((e,t)=>{if(e!=l){let n=Pe+t;ye.create({id:n,contexts:i,title:e,parentId:xe}),n=Me+t;let r=a.profileName==e;ye.create({id:n,type:"radio",contexts:i,title:e,checked:r,parentId:Ee}),ht.set(n,r),n=Ae+t,r=Boolean(d)&&d.profile==e,ye.create({id:n,type:"radio",contexts:i,title:e,checked:r,parentId:We}),ht.set(n,r),vt.set(e,t)}})),n.contextMenuEnabled&&ye.create({id:"separator-3",contexts:r,type:"separator"})}ye.create({id:Ne,contexts:i,title:it}),ye.create({id:qe,type:"radio",title:ct,contexts:i,checked:!0,parentId:Ne}),ht.set(qe,!0),ye.create({id:Fe,type:"radio",title:lt,contexts:i,checked:!1,parentId:Ne}),ht.set(Fe,!1),ye.create({id:ze,type:"radio",title:dt,contexts:i,checked:!1,parentId:Ne}),ht.set(ze,!1),ye.create({id:He,type:"radio",title:ut,contexts:i,checked:!1,parentId:Ne}),ht.set(He,!1),ye.create({id:"separator-4",contexts:i,type:"separator"}),ye.create({id:Te,contexts:i,title:Ve})}wt=!0,pt&&(pt=!1,(await browser.tabs.query({})).forEach((async e=>await xt(e))))}async function It(e){const t=await s(e.id);await async function(){const e=await browser.tabs.query({});return Promise.all(e.map((async e=>{const[t,a]=await Promise.all([x(e.url,!0),W(e)]);try{await browser.tabs.sendMessage(e.id,{method:"content.init",autoSaveEnabled:a,options:t})}catch(e){}})))}(),await we(e);try{await browser.runtime.sendMessage({method:"options.refresh",profileName:t.profileName})}catch(e){}}async function xt(e){if(ve&&wt){const t=[],a=await s(e.id);if(a[e.id].editorDetected)St(!1);else if(St(!0),t.push(Et(qe,!a[e.id].autoSave)),t.push(Et(Fe,a[e.id].autoSave)),t.push(Et(ze,Boolean(a.autoSaveUnpinned))),t.push(Et(He,Boolean(a.autoSaveAll))),e&&e.url){const n=await x(e.url);t.push(async function(e,t){const a=gt;gt=t,(void 0===a||a!=t)&&await kt(e)}(e,n.contextMenuEnabled)),t.push(Tt(Ie,a[e.id].savedPageDetected?Ye:Ze)),t.push(ye.update(Le,{visible:!n.saveRawPage})),t.push(ye.update(Ie,{visible:!n.openEditor||a[e.id].savedPageDetected}));let r="associate-with-profile-default",o=Je;const[s,i]=await Promise.all([I(),b(e.url)]);if(i){const e=vt.get(i.profile);e&&(r=Ae+e,o=Ge)}Object.keys(s).length>1&&(Object.keys(s).forEach(((e,a)=>{e==l?t.push(Et("associate-with-profile-default","associate-with-profile-default"==r)):t.push(Et(Ae+a,r==Ae+a))})),t.push(Tt(We,o)))}await Promise.all(t)}}async function St(e){const t=yt;if(yt=e,void 0===t||t!=e){const t=[];try{ft.forEach((a=>t.push(ye.update(a,{visible:e})))),await Promise.all(t)}catch(e){}}}function Tt(e,t){const a=mt.get(e);return mt.set(e,t),void 0===a||a!=t?ye.update(e,{title:t}):void 0}async function Et(e,t){t=Boolean(t),ht.set(e,t),await ye.update(e,{checked:t})}Promise.resolve().then((async function(){ve&&(kt(),ye.onClicked.addListener((async(e,t)=>{if(e.menuItemId==ke&&(e.linkUrl?bt.saveUrls([e.linkUrl]):bt.saveTabs([t])),e.menuItemId==Ie){(await s(t.id))[t.id].savedPageDetected?bt.openEditor(t):e.linkUrl?bt.saveUrls([e.linkUrl],{openEditor:!0}):bt.saveTabs([t],{openEditor:!0})}if(e.menuItemId==Se&&bt.saveSelectedLinks(t),e.menuItemId==Te&&await browser.tabs.create({active:!0,url:"/src/extension/ui/pages/pendings.html"}),e.menuItemId==Le&&bt.saveTabs([t],{selected:!0}),e.menuItemId==Re&&bt.saveTabs([t],{frameId:e.frameId}),e.menuItemId==Ue||e.menuItemId==De){const e=await G({currentWindow:!0,highlighted:!0});bt.saveTabs(e)}if(e.menuItemId==Be||e.menuItemId==Oe){const e=await G({currentWindow:!0,pinned:!1});bt.saveTabs(e)}if(e.menuItemId==_e||e.menuItemId==je){const e=await G({currentWindow:!0});bt.saveTabs(e)}if(e.menuItemId==Fe){const e=await s(t.id);e[t.id].autoSave=!0,await i(e),It(t)}if(e.menuItemId==qe){const e=await s();Object.keys(e).forEach((t=>{"object"==typeof e[t]&&e[t].autoSave&&(e[t].autoSave=!1)})),e.autoSaveUnpinned=e.autoSaveAll=!1,await i(e),It(t)}if(e.menuItemId==He){const a=await s();a.autoSaveAll=e.checked,await i(a),It(t)}if(e.menuItemId==ze){const a=await s();a.autoSaveUnpinned=e.checked,await i(a),It(t)}if(e.menuItemId.startsWith(Pe)){const a=await I(),n=e.menuItemId.split(Pe)[1];let r;if("default"==n)r=l;else{const e=Number(n);r=Object.keys(a)[e]}a[r].profileName=r,bt.saveTabs([t],a[r])}if(e.menuItemId.startsWith(Me)){const[a,n]=await Promise.all([I(),s()]),r=e.menuItemId.split(Me)[1];if("default"==r)n.profileName=l;else{const e=Number(r);n.profileName=Object.keys(a)[e]}await i(n),It(t)}if(e.menuItemId.startsWith(Ae)){const[a,n]=await Promise.all([I(),b(t.url,!0)]),r=e.menuItemId.split(Ae)[1];let o;if("default"==r)o=l;else if("current"==r)o=c;else{const e=Number(r);o=Object.keys(a)[e]}n?await T(n.url,n.url,o,o):(await Tt(We,Ge),await S(new URL(t.url).hostname,o,o))}})),wt?pt=!0:(await browser.tabs.query({})).forEach((async e=>await xt(e))))}));const Pt=browser.commands;let Mt,Wt,At;function Lt(e,t){return e.method.endsWith(".refreshMenu")?function(e){if(e.method.endsWith("refreshMenu"))return kt(),Promise.resolve({})}(e):de(e,t)}function Rt(e){!function(e){pe(e.id,ge("forbidden"))}(e)}function Ct(e,t,a){!function(e,t,a){let n;a?n=ge("inject",!0):(n=ge(1==t?"inject":"execute"),n.setTitle={title:V+" ("+t+"/2)"},n.setIcon={path:$+"0.png"}),pe(e,n)}(e,t,a)}async function Ut(e,t,a){ue(e),t&&await browser.tabs.sendMessage(e,{method:"content.error",error:t.toString(),link:a})}function Bt(e){!function(e){pe(e,ge("edit"))}(e)}function _t(e,t){fe(e,t)}function Dt(e,t,a){!function(e,t,a){me(e,t,a,ne)}(e,t,a)}function Ot(e){xt(e)}Pt&&Pt.onCommand&&Pt.onCommand.addListener&&Pt.onCommand.addListener((async e=>{if("save-selected-tabs"==e){const e=await G({currentWindow:!0,highlighted:!0});Mt.saveTabs(e,{optionallySelected:!0})}if("save-all-tabs"==e){const e=await G({currentWindow:!0});Mt.saveTabs(e)}}));const jt=["lib/chrome-browser-polyfill.js","lib/single-file.js"],Nt=["lib/chrome-browser-polyfill.js","lib/single-file-frames.js"];async function qt(e,t){let a;if(await async function(e){const t=e.extensionScriptFiles||[];Wt||At||([Wt,At]=await Promise.all([Ft(jt.concat(t)),Ft(Nt)]))}(t),!t.removeFrames)try{await browser.tabs.executeScript(e,{code:At,allFrames:!0,matchAboutBlank:!0,runAt:"document_start"})}catch(e){}try{await browser.tabs.executeScript(e,{code:Wt,allFrames:!1,runAt:"document_idle"}),a=!0}catch(e){}return a&&t.frameId&&await browser.tabs.executeScript(e,{code:"document.documentElement.dataset.requestedFrameId = true",frameId:t.frameId,matchAboutBlank:!0,runAt:"document_start"}),a}async function Ft(e){const t=e.map((async e=>{if("function"==typeof e)return"("+e.toString()+")();";{const t=await fetch(browser.runtime.getURL("../../../"+e));return(new TextDecoder).decode(await t.arrayBuffer())}}));let a="";for(const e of t)a+=await e;return a}const zt="single-file-response-fetch",Ht=(e,t)=>window.fetch(e,t);let Jt=0,Gt=new Map;async function Kt(e,t={}){try{let a=await Ht(e,{cache:"force-cache",headers:t.headers});return 401!=a.status&&403!=a.status&&404!=a.status||(a=await Yt(e)),a}catch(a){Jt++;const n=new Promise(((e,t)=>Gt.set(Jt,{resolve:e,reject:t})));return await Xt({method:"singlefile.fetch",url:e,requestId:Jt,referrer:t.referrer,headers:t.headers}),n}}async function $t(e,t){const a=await Xt({method:"singlefile.fetchFrame",url:e,frameId:t.frameId,referrer:t.referrer,headers:t.headers});return{status:a.status,headers:new Map(a.headers),arrayBuffer:async()=>new Uint8Array(a.array).buffer}}async function Xt(e){const t=await browser.runtime.sendMessage(e);if(!t||t.error)throw new Error(t&&t.error&&t.error.toString());return t}function Yt(e){return new Promise(((t,a)=>{var n,r,o,s;n=new CustomEvent("single-file-request-fetch",{detail:e}),window.dispatchEvent(n),r=zt,o=function n(r){var o,s,i;r.detail?r.detail.url==e&&(o=zt,s=n,i=!1,window.removeEventListener(o,s,i),r.detail.response?t({status:r.detail.status,headers:new Map(r.detail.headers),arrayBuffer:async()=>r.detail.response}):a(r.detail.error)):a()},s=!1,window.addEventListener(r,o,s)}))}function Zt(e,t){return qt(e,t)}browser.runtime.onMessage.addListener((e=>"singlefile.fetchFrame"==e.method&&window.frameId&&window.frameId==e.frameId?async function(e){try{let t=await Ht(e.url,{cache:"force-cache",headers:e.headers});return 401!=t.status&&403!=t.status&&404!=t.status||(t=await Promise.race([Yt(e.url),new Promise(((e,t)=>setTimeout((()=>t()),5e3)))])),{status:t.status,headers:[...t.headers],array:Array.from(new Uint8Array(await t.arrayBuffer()))}}catch(e){return{error:e&&e.toString()}}}(e):"singlefile.fetchResponse"==e.method?async function(e){const t=Gt.get(e.requestId);t&&(e.error?(t.reject(new Error(e.error)),Gt.delete(e.requestId)):(e.truncated&&(t.array?t.array=t.array.concat(e.array):(t.array=e.array,Gt.set(e.requestId,t)),e.finished&&(e.array=t.array)),e.truncated&&!e.finished||(t.resolve({status:e.status,headers:{get:t=>e.headers&&e.headers[t]},arrayBuffer:async()=>new Uint8Array(e.array).buffer}),Gt.delete(e.requestId))));return{}}(e):void 0));const Vt="Could not establish connection. Receiving end does not exist.",Qt="The message port closed before a response was received.",ea="Message manager disconnected",ta="Cannot access contents of url ",aa="pending",na="processing",ra=["lib/infobar.js","lib/extension.js"],oa=[];let sa,ia=0;var ca;async function la(e,t={}){await fa(),await Promise.all(e.map((async e=>{const a=await x(e);Object.keys(t).forEach((e=>a[e]=t[e])),a.autoClose=!0,a.extensionScriptFiles=ra,a.passReferrerOnError&&await H(),ua({tab:{url:e},status:aa,options:a,method:"content.save"})}))),ha()}async function da(e,t={}){await fa(),await Promise.all(e.map((async e=>{const a=e.id,n=await x(e.url);if(Object.keys(t).forEach((e=>n[e]=t[e])),n.tabId=a,n.tabIndex=e.index,n.extensionScriptFiles=ra,n.passReferrerOnError&&await H(),t.autoSave){if(W(e)){ma(ua({status:na,tab:e,options:n,method:"content.autosave"}))}}else{Ct(a,1);await Zt(a,n)||B(e)?(Ct(a,2),ua({status:aa,tab:e,options:n,method:"content.save"})):Rt(e)}}))),ha()}function ua(e){const t={id:ia,status:e.status,tab:e.tab,options:e.options,method:e.method,done:function(){oa.splice(oa.findIndex((e=>e.id==this.id)),1),ha()}};return oa.push(t),ia++,t}async function fa(){sa||(sa=(await g()).maxParallelWorkers)}function ha(){const e=oa.filter((e=>e.status==na)).length;for(let t=0;te.status==aa));e&&ma(e)}}async function ma(e){const t=e.id;if(e.status=na,!e.tab.id){let t;try{const a=await async function(e){const t=await browser.tabs.create(e);return new Promise(((e,a)=>{function n(a,o){a==t.id&&"complete"==o.status&&(e(t),browser.tabs.onUpdated.removeListener(n),browser.tabs.onRemoved.removeListener(r))}function r(e){e==t.id&&(a(e),browser.tabs.onRemoved.removeListener(r))}browser.tabs.onUpdated.addListener(n),browser.tabs.onRemoved.addListener(r)}))}({url:e.tab.url,active:!1});e.tab.id=e.options.tabId=a.id,e.tab.index=e.options.tabIndex=a.index,Ct(e.tab.id,1),t=await Zt(e.tab.id,e.options)}catch(t){e.tab.id=t}if(!t)return void e.done();Ct(e.tab.id,2)}e.options.taskId=t;try{await browser.tabs.sendMessage(e.tab.id,{method:e.method,options:e.options})}catch(t){!t||t.message&&function(e){return e.message==Qt||e.message==Vt||e.message==ea||e.message.startsWith(ta+JSON.stringify(U))}(t)||(console.log(t.message?t.message:t),Ut(e.tab.id,t.message,t.link),e.done())}}function wa(e){const t=oa.find((t=>t.id==e));t&&(t.options.autoClose&&!t.cancelled&&browser.tabs.remove(t.tab.id),t.done())}function pa(e,t){const a=oa.find((t=>t.id==e));a&&(a.cancel=t)}function ba(e){Array.from(oa).filter((t=>t.tab.id==e&&!t.options.autoSave)).forEach(ya)}function ga(e){return oa.find((t=>t.id==e))}function ya(e){const t=e.tab.id;e.cancelled=!0,browser.tabs.sendMessage(t,{method:"content.cancelSave",options:{loadDeferredImages:e.options.loadDeferredImages,loadDeferredImagesKeepZoomLevel:e.options.loadDeferredImagesKeepZoomLevel}}),e.cancel&&e.cancel(),"content.autosave"==e.method&&_t(t,!0),function(e){he(e)}(e.tab),e.done()}function va(e){return{id:e.id,tabId:e.tab.id,index:e.tab.index,url:e.tab.url,title:e.tab.title,cancelled:e.cancelled,status:e.status}}(function(e){bt=e})(ca={isSavingTab:function(e){return Boolean(oa.find((t=>t.tab.id==e.id)))},saveTabs:da,saveUrls:la,cancelTab:ba,openEditor:function(e){browser.tabs.sendMessage(e.id,{method:"content.openEditor"})},saveSelectedLinks:async function(e){const t={extensionScriptFiles:ra,tabId:e.id,tabIndex:e.index};if(await Zt(e.id,t)){const t=await browser.tabs.sendMessage(e.id,{method:"content.getSelectedLinks"});t.urls&&t.urls.length&&await la(t.urls)}else Rt(e)}}),function(e){le=e}(ca),function(e){Mt=e}(ca);async function ka(e){const t=browser.runtime.connectNative("singlefile_companion");t.postMessage({method:"save",pageData:e}),await new Promise(((e,a)=>{t.onDisconnect.addListener((()=>{t.error?a(new Error(t.error.message+" (Companion)")):browser.runtime.lastError&&!browser.runtime.lastError.message.includes("Native host has exited")||e()}))}))}async function Ia(e){return e.method.endsWith(".saveCreatedBookmarks")?(xa(),{}):e.method.endsWith(".disable")?(async function(){let e;const t=await I();Object.keys(t).forEach((a=>e=e||!t[a].saveCreatedBookmarks)),e&&browser.bookmarks.onCreated.removeListener(Sa)}(),{}):void 0}async function xa(){try{browser.bookmarks.onCreated.removeListener(Sa)}catch(e){}let e;const t=await I();Object.keys(t).forEach((a=>{t[a].saveCreatedBookmarks&&(e=!0)})),e&&browser.bookmarks.onCreated.addListener(Sa)}async function Sa(e,t){const a=await browser.tabs.query({lastFocusedWindow:!0,active:!0}),n=await x(t.url);if(n.saveCreatedBookmarks){const o=await async function e(t,a=[]){if(t){const n=(await browser.bookmarks.get(t))[0];n&&n.title&&(a.unshift(n.title),await e(n.parentId,a))}return a}(t.parentId),s=n.allowedBookmarkFolders.toString(),i=o.find((e=>n.allowedBookmarkFolders.includes(e))),c=n.ignoredBookmarkFolders.toString(),l=o.find((e=>n.ignoredBookmarkFolders.includes(e)));if((s&&i||!s)&&(c&&!l||!c))if(a.length&&a[0].url==t.url)da(a,{bookmarkId:e,bookmarkFolders:o});else{const a=await browser.tabs.query({});if(a.length){const n=a.find((e=>e.url==t.url));n?da([n],{bookmarkId:e,bookmarkFolders:o}):t.url&&("about:blank"==t.url?browser.bookmarks.onChanged.addListener((function t(a,n){a==e&&n.url&&(browser.bookmarks.onChanged.removeListener(t),r(n.url))})):r(t.url))}}}function r(t){la([t],{bookmarkId:e})}}Promise.resolve().then(xa);async function Ta(e,t){let a=t||"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhYzZmZTMzMi0wODNjLTRjZmMtYmYxNC0xNWU5MTJmMWY4OWIiLCJpYXQiOjE1NzYxNzQzNDV9.n31j9ctJj7R1Vjwyc5yd1d6Cmg0NDnpwSaLWsqtZJQA";const n=await fetch("https://api.woleet.io/v1/anchor",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:"Bearer "+a},body:JSON.stringify({name:e,hash:e,public:!0})});if(401==n.status){const e=new Error("Your access token on Woleet is invalid. Go to __DOC_LINK__ to create your account.");throw e.link="https://app.woleet.io/",e}if(402==n.status){const e=new Error("You have no more credits on Woleet. Go to __DOC_LINK__ to recharge them.");throw e.link="https://app.woleet.io/",e}if(n.status>=400)throw new Error((n.statusText||"Error "+n.status)+" (Woleet)");return n.json()}const Ea="https://oauth2.googleapis.com/token",Pa="https://www.googleapis.com/drive/v3/files";let Ma,Wa=!0;class Aa{constructor(e){this.file=e.file,this.onProgress=e.onProgress,this.contentType=this.file.type||"application/octet-stream",this.metadata={name:e.filename,mimeType:this.contentType,parents:e.parents||["root"]},this.token=e.token,this.offset=0,this.chunkSize=e.chunkSize||524288}async upload(){const e=Oa(await fetch("https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable",{method:"POST",headers:{Authorization:"Bearer "+this.token,"Content-Type":"application/json","X-Upload-Content-Length":this.file.size,"X-Upload-Content-Type":this.contentType},body:JSON.stringify(this.metadata)})).headers.get("Location");if(this.url=e,!this.cancelled)return this.onProgress&&this.onProgress(0,this.file.size),_a(this)}}async function La(e,t){const a=await fetch(Ea,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"client_id="+e.clientId+"&grant_type=authorization_code&code="+t.code+"&redirect_uri="+e.redirectURI}),n=await Da(a);return e.accessToken=n.access_token,e.refreshToken=n.refresh_token,e.expirationDate=Date.now()+1e3*n.expires_in,{accessToken:e.accessToken,refreshToken:e.refreshToken,expirationDate:e.expirationDate}}function Ra(e,t={}){return e.redirectURI=encodeURIComponent("urn:ietf:wg:oauth:2.0:oob"+(t.auto?":auto":"")),e.authURL="https://accounts.google.com/o/oauth2/v2/auth?client_id="+e.clientId+"&response_type=code&access_type=offline&redirect_uri="+e.redirectURI+"&scope="+e.scopes.join(" "),e.authURL}function Ca(e={}){return Boolean(browser.identity&&browser.identity.getAuthToken)&&!e.forceWebAuthFlow}async function Ua(e,t,a=!0){const n=t.split("/");n.pop();const r=e.folderIds.get(n.join("/"));if(r)return r;let o="root";if(n.length){let r="";for(const s of n){r&&(r+="/"),r+=s;const n=e.folderIds.get(r);if(n)o=n;else try{o=await Ba(e,s,o),e.folderIds.set(r,o)}catch(n){if("path_not_found"==n.message&&a)return e.folderIds.clear(),Ua(e,t,!1);throw n}}}return o}async function Ba(e,t,a){const n=await async function(e,t,a){return Da(await fetch(Pa+"?q=mimeType = 'application/vnd.google-apps.folder' and name = '"+t+"' and trashed != true and '"+a+"' in parents",{headers:{Authorization:"Bearer "+e.accessToken}}))}(e,t,a);if(n.files.length)return n.files[0].id;{const n=await async function(e,t,a){return Da(await fetch(Pa,{method:"POST",headers:{Authorization:"Bearer "+e.accessToken,"Content-Type":"application/json"},body:JSON.stringify({name:t,parents:[a],mimeType:"application/vnd.google-apps.folder"})}))}(e,t,a);return n.id}}async function _a(e){let t=e.file,a=e.file.size;(e.offset||e.chunkSize)&&(e.chunkSize&&(a=Math.min(e.offset+e.chunkSize,e.file.size)),t=t.slice(e.offset,a));const n=await fetch(e.url,{method:"PUT",headers:{Authorization:"Bearer "+e.token,"Content-Type":e.contentType,"Content-Range":"bytes "+e.offset+"-"+(a-1)+"/"+e.file.size,"X-Upload-Content-Type":e.contentType},body:t});if(e.onProgress&&!e.cancelled&&e.onProgress(e.offset+e.chunkSize,e.file.size),200==n.status||201==n.status)return n.json();if(308==n.status){const t=n.headers.get("Range");if(t&&(e.offset=parseInt(t.match(/\d+/g).pop(),10)+1),e.cancelled)throw new Error("upload_cancelled");return _a(e)}Oa(n)}async function Da(e){e=Oa(e);const t=await e.json();if(t.error)throw new Error(t.error);return t}function Oa(e){if(200==e.status)return e;throw 404==e.status?new Error("path_not_found"):401==e.status?new Error("invalid_token"):new Error("unknown_error ("+e.status+")")}async function ja(e,t,a,n,r,o){for(;Ma;)await Ma;const s=new AbortController;return Ma=(async()=>{try{await async function({path:r,content:o,message:s=""},i){try{const c=await fetch(`https://api.github.com/repos/${t}/${a}/contents/${r.replace(/#/g,"%23")}`,{method:"PUT",headers:new Map([["Authorization",`token ${e}`],["Accept","application/vnd.github.v3+json"]]),body:JSON.stringify({content:btoa(unescape(encodeURIComponent(o))),message:s,branch:n}),signal:i}),l=await c.json();if(c.status<400)return l;throw new Error(l.message)}catch(e){if("AbortError"!=e.name)throw e}}({path:r,content:o},s.signal)}finally{Ma=null}})(),{cancelPush:()=>s.abort(),pushPromise:Ma}}const Na=new Map,qa="text/html",Fa=/([{}()^$&.*?/+|[\\\\]|\]|-)/g,za=browser.runtime.getManifest(),Ha=za.optional_permissions&&za.optional_permissions.includes("identity"),Ja=new class{constructor(e,t){this.clientId=e,this.scopes=t,this.folderIds=new Map,setInterval((()=>this.folderIds.clear()),6e4)}async auth(e={interactive:!0,auto:!0}){if(e.requestPermissionIdentity&&Wa)try{await browser.permissions.request({permissions:["identity"]}),Wa=!1}catch(e){}return Ca(e)?(this.accessToken=await browser.identity.getAuthToken({interactive:e.interactive}),{revokableAccessToken:this.accessToken}):(Ra(this,e),e.code?La(this,e):async function(e,t){let a;t.extractAuthCode&&t.extractAuthCode(Ra(e,t)).then((e=>a=e)).catch((()=>{}));try{if(browser.identity&&browser.identity.launchWebAuthFlow&&!t.forceWebAuthFlow)return await browser.identity.launchWebAuthFlow({interactive:t.interactive,url:e.authURL});if(t.launchWebAuthFlow)return await t.launchWebAuthFlow({url:e.authURL});throw new Error("auth_not_supported")}catch(n){if(n.message&&("code_required"==n.message||n.message.includes("access"))){if(t.auto||a||!t.promptAuthCode||(a=await t.promptAuthCode()),a)return t.code=a,await La(e,t);throw new Error("code_required")}throw n}}(this,e))}setAuthInfo(e,t){Ca(t)||(e?(this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationDate=e.expirationDate):(delete this.accessToken,delete this.refreshToken,delete this.expirationDate))}async refreshAuthToken(){if(this.refreshToken){const e=await fetch(Ea,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"client_id="+this.clientId+"&refresh_token="+this.refreshToken+"&grant_type=refresh_token"});if(400==e.status)throw new Error("unknown_token");const t=await Da(e);return this.accessToken=t.access_token,t.refresh_token&&(this.refreshToken=t.refresh_token),t.expires_in&&(this.expirationDate=Date.now()+1e3*t.expires_in),{accessToken:this.accessToken,refreshToken:this.refreshToken,expirationDate:this.expirationDate}}}async revokeAuthToken(e){if(e){if(browser.identity&&browser.identity.removeCachedAuthToken)try{await browser.identity.removeCachedAuthToken({token:e})}catch(e){}const t=await fetch("https://accounts.google.com/o/oauth2/revoke",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"token="+e});try{await Da(t)}catch(e){if("invalid_token"!=e.message)throw e}finally{delete this.accessToken,delete this.refreshToken,delete this.expirationDate}}}async upload(e,t,a,n=!0){const r=await Ua(this,e),o=e.split("/").pop(),s=new Aa({token:this.accessToken,file:t,parents:[r],filename:o,onProgress:a.onProgress});try{return{cancelUpload:()=>s.cancelled=!0,uploadPromise:s.upload()}}catch(r){if("path_not_found"==r.message&&n)return this.folderIds.clear(),this.upload(e,t,a,!1);throw r}}}("207618107333-3pj2pmelhnl4sf3rpctghs9cean3q8nj.apps.googleusercontent.com",["https://www.googleapis.com/auth/drive.file"]);async function Ga(e,t){if(e.method.endsWith(".download"))return async function(e,t){let a;e.truncated?(a=Na.get(t.id),a||(a=[],Na.set(t.id,a)),a.push(e.content),e.finished&&Na.delete(t.id)):e.content&&(a=[e.content]);e.truncated&&!e.finished||(e.openEditor?(Bt(t.id),await async function({tabIndex:e,content:t,filename:a}){const n={active:!0,url:L};null!=e&&(n.index=e);const r=await browser.tabs.create(n);R.set(r.id,{content:t,filename:a})}({tabIndex:t.index+1,filename:e.filename,content:a.join("")})):e.saveToClipboard?(e.content=a.join(""),function(e){const t="copy";function a(t){t.clipboardData.setData(qa,e.content),t.clipboardData.setData("text/plain",e.content),t.preventDefault()}document.addEventListener(t,a),document.execCommand(t),document.removeEventListener(t,a)}(e),_t(t.id)):await async function(e,t,a,n){try{if(n.saveToGDrive?await(await Xa(n.taskId,n.filename,new Blob(e,{type:qa}),{forceWebAuthFlow:n.forceWebAuthFlow,extractAuthCode:n.extractAuthCode},{onProgress:(e,a)=>Dt(t.id,e,a)})).uploadPromise:n.saveToGitHub?await(await $a(n.taskId,n.filename,e.join(""),n.githubToken,n.githubUser,n.githubRepository,n.githubBranch)).pushPromise:n.saveWithCompanion?await ka({filename:n.filename,content:n.content,filenameConflictAction:n.filenameConflictAction}):(n.url=URL.createObjectURL(new Blob(e,{type:qa})),await Ya(n,{confirmFilename:n.confirmFilename,incognito:a,filenameConflictAction:n.filenameConflictAction,filenameReplacementCharacter:n.filenameReplacementCharacter,includeInfobar:n.includeInfobar})),_t(t.id),n.openSavedPage){const a={active:!0,url:URL.createObjectURL(new Blob(e,{type:qa}))};null!=t.index&&(a.index=t.index+1),browser.tabs.create(a)}}catch(e){e.message&&"upload_cancelled"==e.message||(console.error(e),Ut(t.id,e.message,e.link))}finally{n.url&&URL.revokeObjectURL(n.url)}}(a,t,t.incognito,e));return{}}(e,t.tab);if(e.method.endsWith(".disableGDrive")){const e=await E();return M(),await Ja.revokeAuthToken(e&&(e.accessToken||e.revokableAccessToken)),{}}if(e.method.endsWith(".end")){if(e.hash)try{await Ta(e.hash,e.woleetKey)}catch(e){Ut(t.tab.id,e.message,e.link)}return wa(e.taskId),{}}return e.method.endsWith(".getInfo")?oa.map(va):e.method.endsWith(".cancel")?(a=e.taskId,ya(oa.find((e=>e.id==a))),{}):e.method.endsWith(".cancelAll")?(Array.from(oa).forEach(ya),{}):e.method.endsWith(".saveUrls")?(la(e.urls),{}):void 0;var a}async function Ka(e,t){let a=await E();const n={interactive:!0,auto:e.extractAuthCode,forceWebAuthFlow:e.forceWebAuthFlow,requestPermissionIdentity:Ha,launchWebAuthFlow:e=>async function(e){const t=await browser.tabs.create({url:e.url,active:!0});return new Promise(((e,a)=>{browser.tabs.onRemoved.addListener((function e(n){n==t.id&&(browser.tabs.onRemoved.removeListener(e),a(new Error("code_required")))}))}))}(e),extractAuthCode:e=>function(e){return new Promise(((t,a)=>{let n;function r(a,s){s&&s.url==e&&(n=a),n==a&&s&&s.title&&s.title.startsWith("Success code=")&&(browser.tabs.onUpdated.removeListener(r),browser.tabs.onUpdated.removeListener(o),t(s.title.substring(13,s.title.length-49)))}function o(e){e==n&&(browser.tabs.onUpdated.removeListener(r),browser.tabs.onUpdated.removeListener(o),a())}browser.tabs.onUpdated.addListener(r),browser.tabs.onRemoved.addListener(o)}))}(e),promptAuthCode:()=>async function(e){const t=await browser.tabs.query({currentWindow:!0,active:!0});return new Promise(((a,n)=>{const r=t[0].id;browser.tabs.onRemoved.addListener((function e(t){t==r&&(J.delete(t),browser.tabs.onUpdated.removeListener(e),n())})),J.set(r,{resolve:a,reject:n}),browser.tabs.sendMessage(r,{method:"common.promptValueRequest",promptMessage:e})}))}("Please enter the access code for Google Drive")};return Ja.setAuthInfo(a,n),a&&a.accessToken&&!t||(a=await Ja.auth(n),a?await P(a):await M()),a}async function $a(e,t,a,n,r,o,s){const i=ga(e);if(!i||!i.cancelled){const i=ja(n,r,o,s,t,a);pa(e,i.cancelPush);try{return await(await i).pushPromise,i}catch(e){throw new Error(e.message+" (GitHub)")}}}async function Xa(e,t,a,n,r){try{await Ka(n);const o=ga(e);if(!o||!o.cancelled){const n=await Ja.upload(t,a,r);return pa(e,n.cancelUpload),n}}catch(o){if("invalid_token"!=o.message)throw new Error(o.message+" (Google Drive)");{let o;try{o=await Ja.refreshAuthToken()}catch(e){if("unknown_token"!=e.message)throw new Error(e.message+" (Google Drive)");o=await Ka(n,!0)}o?await P(o):await M(),await Xa(e,t,a,n,r)}}}async function Ya(t,a){let n;if("skip"==a.filenameConflictAction){(await browser.downloads.search({filenameRegex:"(\\\\|/)"+(r=t.filename,r.replace(Fa,"\\$1")+"$"),exists:!0})).length?n=!0:a.filenameConflictAction="uniquify"}var r;if(!n){const n={url:t.url,saveAs:a.confirmFilename,filename:t.filename,conflictAction:a.filenameConflictAction};a.incognito&&(n.incognito=!0);const r=await e(n,a.filenameReplacementCharacter);r.filename&&t.bookmarkId&&t.replaceBookmarkURL&&(r.filename.startsWith("file:")||(r.filename.startsWith("/")&&(r.filename=r.filename.substring(1)),r.filename="file:///"+r.filename.replace(/#/g,"%23")),await async function(e,t){try{await browser.bookmarks.update(e,t)}catch(e){}}(t.bookmarkId,{url:r.filename}))}}const Za={},Va={};async function Qa(e,t){if("enableAutoSave"==e.method){const a=await s(t.id);a[t.id].autoSave=e.enabled,await i(a),async function(e){Promise.all([kt(e),we(e)])}(t)}if("isAutoSaveEnabled"==e.method)return W(t)}async function en(e,t){const a=t.id,n=await x(t.url,!0);if(n){let r;Ct(a,1,!0),n.content=e.content,n.url=e.url,n.frames=e.frames,n.canvases=e.canvases,n.fonts=e.fonts,n.stylesheets=e.stylesheets,n.images=e.images,n.posters=e.posters,n.usedFonts=e.usedFonts,n.shadowRoots=e.shadowRoots,n.imports=e.imports,n.referrer=e.referrer,n.updatedResources=e.updatedResources,n.visitDate=new Date(e.visitDate),n.backgroundTab=!0,n.autoSave=!0,n.incognito=t.incognito,n.tabId=a,n.tabIndex=t.index;try{if(n.autoSaveExternalSave)await async function(e){e.autoSaveExternalSave=!1;const t=browser.runtime.connectNative("singlefile_companion");t.postMessage({method:"externalSave",pageData:e}),await new Promise(((e,a)=>{t.onDisconnect.addListener((()=>{t.error?a(new Error(t.error.message+" (Companion)")):browser.runtime.lastError&&!browser.runtime.lastError.message.includes("Native host has exited")||e()}))}))}(n);else{if(r=await function(e,t,a,n={fetch:Kt,frameFetch:$t}){return globalThis.singlefile.getPageData(e,n,t,a)}(n,null,null,{fetch:tn}),n.includeInfobar&&await infobar.includeScript(r),n.saveToGDrive){const t=new Blob([r.content],{type:"text/html"});await(await Xa(e.taskId,r.filename,t,n,{})).uploadPromise}else if(n.saveToGitHub)await(await $a(e.taskId,r.filename,r.content,n.githubToken,n.githubUser,n.githubRepository,n.githubBranch)).pushPromise;else if(n.saveWithCompanion)await ka({filename:r.filename,content:r.content,filenameConflictAction:r.filenameConflictAction});else{const e=new Blob([r.content],{type:"text/html"});if(r.url=URL.createObjectURL(e),await Ya(r,n),n.openSavedPage){const n={active:!0,url:URL.createObjectURL(e),windowId:t.windowId},r=t.index;try{await browser.tabs.get(a),n.index=r+1}catch(e){n.index=r}browser.tabs.create(n)}}r.hash&&await Ta(r.hash,n.woleetKey)}}finally{e.taskId?wa(e.taskId):n.autoClose&&(browser.tabs.remove(Va[a]||a),delete Va[a]),r&&r.url&&URL.revokeObjectURL(r.url),_t(a,!0)}}}function tn(e,t={}){return new Promise(((a,n)=>{const r=new XMLHttpRequest;if(r.withCredentials=!0,r.responseType="arraybuffer",r.onerror=e=>n(new Error(e.detail)),r.onreadystatechange=()=>{r.readyState==XMLHttpRequest.DONE&&a({status:r.status,headers:{get:e=>r.getResponseHeader(e)},arrayBuffer:async()=>r.response})},r.open("GET",e,!0),t.headers)for(const e of Object.entries(t.headers))r.setRequestHeader(e[0],e[1]);r.send()}))}async function an(e,t){if(e.method.endsWith(".init")&&(await async function(e,t){await r(e.id);const a=await s(e.id);a[e.id].savedPageDetected=t.savedPageDetected,await i(a)}(t.tab,e),xt(t.tab),function(e){ba(e.id)}(t.tab),async function(e){const[t,a]=await Promise.all([x(e.url,!0),W(e)]);t&&(t.autoSaveLoad||t.autoSaveLoadOrUnload)&&a&&da([e],{autoSave:!0})}(t.tab)),e.method.endsWith(".promptValueResponse")&&async function(e,t){const a=J.get(t.tab.id);a&&(a.resolve(e.value),J.delete(t.tab.id))}(e,t),e.method.endsWith(".getOptions"))return x(e.url);e.method.endsWith(".activate")&&await browser.tabs.update(e.tabId,{active:!0})}browser.tabs.onCreated.addListener((e=>function(e){!function(e){xt(e)}(e)}(e))),browser.tabs.onActivated.addListener((e=>async function(e){Ot(await browser.tabs.get(e.tabId))}(e))),browser.tabs.onRemoved.addListener((e=>function(e){r(e),function(e){R.delete(e)}(e),ba(e),async function(e){const t=Za[e];t?t.autoSaveRemove&&(delete Za[e],await en(t,t.tab)):Za[e]={removed:!0}}(e)}(e))),browser.tabs.onUpdated.addListener(((e,t)=>async function(e,t){if("complete"==t.status){setTimeout((async()=>{try{await browser.tabs.sendMessage(e,{method:"content.maybeInit"})}catch(e){}}),1500),function(e){delete Za[e]}(e);const t=await browser.tabs.get(e);if(B(t)){const e=await s(t.id);e[t.id].editorDetected=!0,await i(e),Ot(t)}}t.discarded&&async function(e){const t=Za[e];t?(delete Za[e],await en(t,t.tab)):Za[e]={discarded:!0}}(e)}(e,t))),browser.tabs.onReplaced.addListener(((e,t)=>function(e,t){!async function(e,t){Za[t]&&!Za[e]&&(Za[e]=Za[t],delete Za[t],Va[t]=e);const a=await s();a[t]&&!a[e]&&(a[e]=a[t],delete a[t],await i(a))}(e,t)}(e,t))),browser.runtime.onMessage.addListener(((e,t)=>{if("singlefile.frameTree.initResponse"==e.method||"singlefile.frameTree.ackInitRequest"==e.method)return browser.tabs.sendMessage(t.tab.id,e,{frameId:0}),Promise.resolve({})}));const nn=new Map;function rn(e,t){e.delete(t)}browser.runtime.onMessage.addListener(((e,t)=>{if("singlefile.lazyTimeout.setTimeout"==e.method){let a,n=nn.get(t.tab.id);if(n)if(a=n.get(t.frameId),a){const t=a.get(e.type);t&&clearTimeout(t)}else a=new Map;const r=setTimeout((async()=>{try{const a=nn.get(t.tab.id),n=a.get(t.frameId);a&&n&&rn(n,e.type),await browser.tabs.sendMessage(t.tab.id,{method:"singlefile.lazyTimeout.onTimeout",type:e.type})}catch(e){}}),e.delay);return n||(n=new Map,a=new Map,n.set(t.frameId,a),nn.set(t.tab.id,n)),a.set(e.type,r),Promise.resolve({})}if("singlefile.lazyTimeout.clearTimeout"==e.method){let a=nn.get(t.tab.id);if(a){const n=a.get(t.frameId);if(n){const t=n.get(e.type);t&&clearTimeout(t),rn(n,e.type)}}return Promise.resolve({})}})),browser.tabs.onRemoved.addListener((e=>nn.delete(e))),browser.runtime.onMessage.addListener(((e,t)=>e.method.startsWith("tabs.")?an(e,t):e.method.startsWith("downloads.")?Ga(e,t):e.method.startsWith("autosave.")?async function(e,t){if(e.method.endsWith(".save"))return e.autoSaveDiscard||e.autoSaveRemove?(t.tab?(e.tab=t.tab,Za[t.tab.id]=e):Za[e.tabId]&&(Za[e.tabId].removed&&e.autoSaveRemove||Za[e.tabId].discarded&&e.autoSaveDiscard)&&(delete Za[e.tabId],await en(e,{id:e.tabId,index:e.tabIndex,url:t.url})),e.autoSaveUnload&&(delete Za[e.tabId],await en(e,t.tab))):(delete Za[e.tabId],await en(e,t.tab)),{}}(e,t):e.method.startsWith("ui.")?Lt(e,t):e.method.startsWith("config.")?k(e):e.method.startsWith("tabsData.")?function(e){return e.method.endsWith(".get")?s():e.method.endsWith(".set")?i(e.tabsData):void 0}(e):e.method.startsWith("devtools.")?async function(e){e.method.endsWith(".resourceCommitted")&&e.tabId&&e.url&&("stylesheet"==e.type||"script"==e.type)&&await browser.tabs.sendMessage(e.tabId,e)}(e):e.method.startsWith("editor.")?async function(e,t){if(e.method.endsWith(".getTabData")){const e=t.tab,a=R.get(e.id);if(a){const t=await x(a.url),n=JSON.stringify(a);for(let a=0;a*AA,r.truncated?(r.finished=(a+1)*A>n.length,r.content=n.substring(a*A,(a+1)*A)):(r.content=n,r.options=t),await browser.tabs.sendMessage(e.id,r)}}}if(e.method.endsWith(".open")){let a;const n=t.tab;if(e.truncated?(a=C.get(n.id),a||(a=[],C.set(n.id,a)),a.push(e.content),e.finished&&C.delete(n.id)):e.content&&(a=[e.content]),!e.truncated||e.finished){const t={url:L};await browser.tabs.update(n.id,t),R.set(n.id,{url:n.url,content:a.join(""),filename:e.filename})}}}(e,t):e.method.startsWith("bookmarks.")?Ia(e):e.method.startsWith("companion.")?async function(e){if(e.method.endsWith(".state"))return{enabled:!0}}(e):e.method.startsWith("requests.")?F(e):e.method.startsWith("bootstrap.")?async function(e,t){if(e.method.endsWith(".init")){const[e,a]=await Promise.all([x(t.tab.url,!0),W(t.tab)]);return{options:e,autoSaveEnabled:a,tabId:t.tab.id,tabIndex:t.tab.index}}}(e,t):void 0)),browser.runtime.onMessageExternal&&browser.runtime.onMessageExternal.addListener((async(e,t)=>{const a=(await browser.tabs.query({currentWindow:!0,active:!0}))[0];return!!a&&Qa(e,a)}))}(); diff --git a/dist/extension-bootstrap.js b/lib/extension-bootstrap.js similarity index 100% rename from dist/extension-bootstrap.js rename to lib/extension-bootstrap.js diff --git a/lib/extension-core.js b/lib/extension-core.js new file mode 100644 index 000000000..cc7c79a90 --- /dev/null +++ b/lib/extension-core.js @@ -0,0 +1 @@ +!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).extension={})}(this,(function(e){"use strict";let r,t;const a=["lib/chrome-browser-polyfill.js","lib/single-file.js"],s=["lib/chrome-browser-polyfill.js","lib/single-file-frames.js"];async function n(e,n){let o;if(await async function(e){const n=e.extensionScriptFiles||[];r||t||([r,t]=await Promise.all([i(a.concat(n)),i(s)]))}(n),!n.removeFrames)try{await browser.tabs.executeScript(e,{code:t,allFrames:!0,matchAboutBlank:!0,runAt:"document_start"})}catch(e){}try{await browser.tabs.executeScript(e,{code:r,allFrames:!1,runAt:"document_idle"}),o=!0}catch(e){}return o&&n.frameId&&await browser.tabs.executeScript(e,{code:"document.documentElement.dataset.requestedFrameId = true",frameId:n.frameId,matchAboutBlank:!0,runAt:"document_start"}),o}async function i(e){const r=e.map((async e=>{if("function"==typeof e)return"("+e.toString()+")();";{const r=await fetch(browser.runtime.getURL("../../../"+e));return(new TextDecoder).decode(await r.arrayBuffer())}}));let t="";for(const e of r)t+=await e;return t}const o="single-file-response-fetch",c=(e,r)=>window.fetch(e,r);let u=0,d=new Map;async function f(e,r={}){try{let t=await c(e,{cache:"force-cache",headers:r.headers});return 401!=t.status&&403!=t.status&&404!=t.status||(t=await w(e)),t}catch(t){u++;const a=new Promise(((e,r)=>d.set(u,{resolve:e,reject:r})));return await h({method:"singlefile.fetch",url:e,requestId:u,referrer:r.referrer,headers:r.headers}),a}}async function l(e,r){const t=await h({method:"singlefile.fetchFrame",url:e,frameId:r.frameId,referrer:r.referrer,headers:r.headers});return{status:t.status,headers:new Map(t.headers),arrayBuffer:async()=>new Uint8Array(t.array).buffer}}async function h(e){const r=await browser.runtime.sendMessage(e);if(!r||r.error)throw new Error(r&&r.error&&r.error.toString());return r}function w(e){return new Promise(((r,t)=>{var a,s,n,i;a=new CustomEvent("single-file-request-fetch",{detail:e}),window.dispatchEvent(a),s=o,n=function a(s){var n,i,c;s.detail?s.detail.url==e&&(n=o,i=a,c=!1,window.removeEventListener(n,i,c),s.detail.response?r({status:s.detail.status,headers:new Map(s.detail.headers),arrayBuffer:async()=>s.detail.response}):t(s.detail.error)):t()},i=!1,window.addEventListener(s,n,i)}))}browser.runtime.onMessage.addListener((e=>"singlefile.fetchFrame"==e.method&&window.frameId&&window.frameId==e.frameId?async function(e){try{let r=await c(e.url,{cache:"force-cache",headers:e.headers});return 401!=r.status&&403!=r.status&&404!=r.status||(r=await Promise.race([w(e.url),new Promise(((e,r)=>setTimeout((()=>r()),5e3)))])),{status:r.status,headers:[...r.headers],array:Array.from(new Uint8Array(await r.arrayBuffer()))}}catch(e){return{error:e&&e.toString()}}}(e):"singlefile.fetchResponse"==e.method?async function(e){const r=d.get(e.requestId);r&&(e.error?(r.reject(new Error(e.error)),d.delete(e.requestId)):(e.truncated&&(r.array?r.array=r.array.concat(e.array):(r.array=e.array,d.set(e.requestId,r)),e.finished&&(e.array=r.array)),e.truncated&&!e.finished||(r.resolve({status:e.status,headers:{get:r=>e.headers&&e.headers[r]},arrayBuffer:async()=>new Uint8Array(e.array).buffer}),d.delete(e.requestId))));return{}}(e):void 0)),e.getPageData=function(e,r,t,a={fetch:f,frameFetch:l}){return globalThis.singlefile.getPageData(e,a,r,t)},e.injectScript=function(e,r){return n(e,r)},Object.defineProperty(e,"__esModule",{value:!0})})); diff --git a/dist/extension-frames.js b/lib/extension-frames.js similarity index 100% rename from dist/extension-frames.js rename to lib/extension-frames.js diff --git a/dist/extension.js b/lib/extension.js similarity index 100% rename from dist/extension.js rename to lib/extension.js diff --git a/lib/infobar.js b/lib/infobar.js new file mode 100644 index 000000000..05fe4d759 --- /dev/null +++ b/lib/infobar.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).infobar={})}(this,(function(e){"use strict";const t="/lib/web/infobar-web.js",n=globalThis.browser;e.includeScript=async function(e){let i,o;for(n&&n.runtime&&n.runtime.getURL?i=await(await fetch(n.runtime.getURL(t))).text():singlefile.getFileContent&&(i=singlefile.getFileContent(t));o!=i;)o=i,i=i.replace(/\/\*(.|\n)*?\*\//,"");i=i.replace(/\t+/g," ").replace(/\nthis\.[^(]*/gi,"\n").replace(/\n+/g,""),e.content+=""); + content = content.replace(/"); const contentDocument = (new DOMParser()).parseFromString(content, "text/html"); if (detectSavedPage(contentDocument)) { if (contentDocument.doctype) { diff --git a/dist/web/hooks/hooks-frames-web.js b/lib/web/hooks/hooks-frames-web.js similarity index 100% rename from dist/web/hooks/hooks-frames-web.js rename to lib/web/hooks/hooks-frames-web.js diff --git a/dist/web/hooks/hooks-web.js b/lib/web/hooks/hooks-web.js similarity index 100% rename from dist/web/hooks/hooks-web.js rename to lib/web/hooks/hooks-web.js diff --git a/dist/web/infobar-web.js b/lib/web/infobar-web.js similarity index 100% rename from dist/web/infobar-web.js rename to lib/web/infobar-web.js diff --git a/manifest.json b/manifest.json index cf3dd9bd9..13f201be4 100644 --- a/manifest.json +++ b/manifest.json @@ -3,10 +3,10 @@ "author": "Gildas Lormeau", "homepage_url": "https://github.com/gildas-lormeau/SingleFile", "icons": { - "16": "extension/ui/resources/icon_16.png", - "48": "extension/ui/resources/icon_48.png", - "64": "extension/ui/resources/icon_64.png", - "128": "extension/ui/resources/icon_128.png" + "16": "src/extension/ui/resources/icon_16.png", + "48": "src/extension/ui/resources/icon_48.png", + "64": "src/extension/ui/resources/icon_64.png", + "128": "src/extension/ui/resources/icon_128.png" }, "version": "1.19.30", "description": "__MSG_extensionDescription__", @@ -17,9 +17,9 @@ ], "run_at": "document_start", "js": [ - "dist/chrome-browser-polyfill.js", - "dist/single-file-frames.js", - "dist/extension-frames.js" + "lib/chrome-browser-polyfill.js", + "lib/single-file-frames.js", + "lib/extension-frames.js" ], "all_frames": true, "match_about_blank": true @@ -30,36 +30,36 @@ ], "run_at": "document_start", "js": [ - "dist/chrome-browser-polyfill.js", - "dist/single-file-bootstrap.js", - "dist/extension-bootstrap.js", - "dist/web/infobar-web.js" + "lib/chrome-browser-polyfill.js", + "lib/single-file-bootstrap.js", + "lib/extension-bootstrap.js", + "lib/web/infobar-web.js" ] } ], "background": { - "page": "extension/core/bg/background.html", + "page": "src/extension/core/bg/background.html", "persistent": false }, - "options_page": "extension/ui/pages/options.html", + "options_page": "src/extension/ui/pages/options.html", "sidebar_action": { "browser_style": true, "default_title": "SingleFile", - "default_panel": "extension/ui/pages/panel.html", - "default_icon": "extension/ui/resources/icon_128.png", + "default_panel": "src/extension/ui/pages/panel.html", + "default_icon": "src/extension/ui/resources/icon_128.png", "open_at_install": false }, "options_ui": { "browser_style": true, - "page": "extension/ui/pages/options.html", + "page": "src/extension/ui/pages/options.html", "open_in_tab": false }, "browser_action": { "default_icon": { - "16": "extension/ui/resources/icon_16.png", - "48": "extension/ui/resources/icon_48.png", - "64": "extension/ui/resources/icon_64.png", - "128": "extension/ui/resources/icon_128.png" + "16": "src/extension/ui/resources/icon_16.png", + "48": "src/extension/ui/resources/icon_48.png", + "64": "src/extension/ui/resources/icon_64.png", + "128": "src/extension/ui/resources/icon_128.png" }, "default_title": "__MSG_buttonDefaultTooltip__" }, @@ -78,17 +78,17 @@ } }, "web_accessible_resources": [ - "dist/web/hooks/hooks-web.js", - "dist/web/hooks/hooks-frames-web.js", - "dist/web/infobar-web.js", - "dist/web/editor/editor-init-web.js", - "dist/web/editor/editor-web.js", - "dist/web/editor/editor-helper-web.js", - "extension/lib/readability/Readability.js", - "extension/lib/readability/Readability-readerable.js", - "extension/ui/pages/editor-note-web.css", - "extension/ui/pages/editor-mask-web.css", - "extension/ui/pages/editor-frame-web.css" + "lib/web/hooks/hooks-web.js", + "lib/web/hooks/hooks-frames-web.js", + "lib/web/infobar-web.js", + "lib/web/editor/editor-init-web.js", + "lib/web/editor/editor-web.js", + "lib/web/editor/editor-helper-web.js", + "src/extension/lib/readability/Readability.js", + "src/extension/lib/readability/Readability-readerable.js", + "src/extension/ui/pages/editor-note-web.css", + "src/extension/ui/pages/editor-mask-web.css", + "src/extension/ui/pages/editor-frame-web.css" ], "oauth2": { "client_id": "207618107333-3pj2pmelhnl4sf3rpctghs9cean3q8nj.apps.googleusercontent.com", @@ -118,7 +118,7 @@ "id": "{531906d3-e22f-4a6c-a102-8057b88a1a63}" } }, - "devtools_page": "extension/core/devtools/devtools.html", + "devtools_page": "src/extension/core/devtools/devtools.html", "incognito": "spanning", "manifest_version": 2, "default_locale": "en" diff --git a/rollup.config.dev.js b/rollup.config.dev.js index f22cf68a6..0b93e5757 100644 --- a/rollup.config.dev.js +++ b/rollup.config.dev.js @@ -1,125 +1,125 @@ export default [{ - input: ["lib/single-file/index.js"], + input: ["src/single-file/index.js"], output: [{ - file: "dist/single-file.js", + file: "lib/single-file.js", format: "umd", name: "singlefile", plugins: [] }] }, { - input: ["lib/single-file/single-file-frames.js"], + input: ["src/single-file/single-file-frames.js"], output: [{ - file: "dist/single-file-frames.js", + file: "lib/single-file-frames.js", format: "umd", name: "singlefile", plugins: [] }] }, { - input: ["lib/single-file/single-file-bootstrap.js"], + input: ["src/single-file/single-file-bootstrap.js"], output: [{ - file: "dist/single-file-bootstrap.js", + file: "lib/single-file-bootstrap.js", format: "umd", name: "singlefileBootstrap", plugins: [] }] }, { - input: ["common/ui/content/content-infobar.js"], + input: ["src/common/ui/content/content-infobar.js"], output: [{ - file: "dist/infobar.js", + file: "lib/infobar.js", format: "umd", name: "infobar", plugins: [] }] }, { - input: ["extension/core/content/content-bootstrap.js"], + input: ["src/extension/core/content/content-bootstrap.js"], output: [{ - file: "dist/extension-bootstrap.js", + file: "lib/extension-bootstrap.js", format: "iife", plugins: [] }] }, { - input: ["extension/core/content/content-frames.js"], + input: ["src/extension/core/content/content-frames.js"], output: [{ - file: "dist/extension-frames.js", + file: "lib/extension-frames.js", format: "iife", plugins: [] }] }, { - input: ["extension/index.js"], + input: ["src/extension/index.js"], output: [{ - file: "dist/extension-core.js", + file: "lib/extension-core.js", format: "umd", name: "extension", plugins: [] }] }, { - input: ["extension/core/content/content.js"], + input: ["src/extension/core/content/content.js"], output: [{ - file: "dist/extension.js", + file: "lib/extension.js", format: "iife", plugins: [] }] }, { - input: ["lib/single-file/processors/hooks/content/content-hooks-web.js"], + input: ["src/single-file/processors/hooks/content/content-hooks-web.js"], output: [{ - file: "dist/web/hooks/hooks-web.js", + file: "lib/web/hooks/hooks-web.js", format: "iife", plugins: [] }] }, { - input: ["lib/single-file/processors/hooks/content/content-hooks-frames-web.js"], + input: ["src/single-file/processors/hooks/content/content-hooks-frames-web.js"], output: [{ - file: "dist/web/hooks/hooks-frames-web.js", + file: "lib/web/hooks/hooks-frames-web.js", format: "iife", plugins: [] }] }, { - input: ["common/ui/content/content-infobar-web.js"], + input: ["src/common/ui/content/content-infobar-web.js"], output: [{ - file: "dist/web/infobar-web.js", + file: "lib/web/infobar-web.js", format: "iife", plugins: [] }] }, { - input: ["extension/ui/content/content-ui-editor-init-web.js"], + input: ["src/extension/ui/content/content-ui-editor-init-web.js"], output: [{ - file: "dist/web/editor/editor-init-web.js", + file: "lib/web/editor/editor-init-web.js", format: "iife", plugins: [] }] }, { - input: ["extension/ui/content/content-ui-editor-web.js"], + input: ["src/extension/ui/content/content-ui-editor-web.js"], output: [{ - file: "dist/web/editor/editor-web.js", + file: "lib/web/editor/editor-web.js", format: "iife", plugins: [] }] }, { - input: ["extension/ui/content/content-ui-editor-helper-web"], + input: ["src/extension/ui/content/content-ui-editor-helper-web"], output: [{ - file: "dist/web/editor/editor-helper-web.js", + file: "lib/web/editor/editor-helper-web.js", format: "umd", name: "singlefile", plugins: [] }] }, { - input: ["extension/lib/single-file/browser-polyfill/chrome-browser-polyfill.js"], + input: ["src/extension/lib/single-file/browser-polyfill/chrome-browser-polyfill.js"], output: [{ - file: "dist/chrome-browser-polyfill.js", + file: "lib/chrome-browser-polyfill.js", format: "iife", plugins: [] }] }, { - input: ["extension/core/bg/index.js"], + input: ["src/extension/core/bg/index.js"], output: [{ - file: "dist/extension-background.js", + file: "lib/extension-background.js", format: "iife", plugins: [] }] }, { - input: ["extension/lib/single-file/background.js"], + input: ["src/extension/lib/single-file/background.js"], output: [{ - file: "dist/single-file-background.js", + file: "lib/single-file-background.js", format: "iife", plugins: [] }] diff --git a/rollup.config.js b/rollup.config.js index cfd188251..140028623 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,127 +1,127 @@ import { terser } from "rollup-plugin-terser"; export default [{ - input: ["lib/single-file/index.js"], + input: ["src/single-file/index.js"], output: [{ - file: "dist/single-file.js", + file: "lib/single-file.js", format: "umd", name: "singlefile", plugins: [terser()] }] }, { - input: ["lib/single-file/single-file-frames.js"], + input: ["src/single-file/single-file-frames.js"], output: [{ - file: "dist/single-file-frames.js", + file: "lib/single-file-frames.js", format: "umd", name: "singlefile", plugins: [terser()] }] }, { - input: ["lib/single-file/single-file-bootstrap.js"], + input: ["src/single-file/single-file-bootstrap.js"], output: [{ - file: "dist/single-file-bootstrap.js", + file: "lib/single-file-bootstrap.js", format: "umd", name: "singlefileBootstrap", plugins: [terser()] }] }, { - input: ["common/ui/content/content-infobar.js"], + input: ["src/common/ui/content/content-infobar.js"], output: [{ - file: "dist/infobar.js", + file: "lib/infobar.js", format: "umd", name: "infobar", plugins: [terser()] }] }, { - input: ["extension/core/content/content-bootstrap.js"], + input: ["src/extension/core/content/content-bootstrap.js"], output: [{ - file: "dist/extension-bootstrap.js", + file: "lib/extension-bootstrap.js", format: "iife", plugins: [terser()] }] }, { - input: ["extension/core/content/content-frames.js"], + input: ["src/extension/core/content/content-frames.js"], output: [{ - file: "dist/extension-frames.js", + file: "lib/extension-frames.js", format: "iife", plugins: [terser()] }] }, { - input: ["extension/index.js"], + input: ["src/extension/index.js"], output: [{ - file: "dist/extension-core.js", + file: "lib/extension-core.js", format: "umd", name: "extension", plugins: [terser()] }] }, { - input: ["extension/core/content/content.js"], + input: ["src/extension/core/content/content.js"], output: [{ - file: "dist/extension.js", + file: "lib/extension.js", format: "iife", plugins: [terser()] }] }, { - input: ["lib/single-file/processors/hooks/content/content-hooks-web.js"], + input: ["src/single-file/processors/hooks/content/content-hooks-web.js"], output: [{ - file: "dist/web/hooks/hooks-web.js", + file: "lib/web/hooks/hooks-web.js", format: "iife", plugins: [terser()] }] }, { - input: ["lib/single-file/processors/hooks/content/content-hooks-frames-web.js"], + input: ["src/single-file/processors/hooks/content/content-hooks-frames-web.js"], output: [{ - file: "dist/web/hooks/hooks-frames-web.js", + file: "lib/web/hooks/hooks-frames-web.js", format: "iife", plugins: [terser()] }] }, { - input: ["common/ui/content/content-infobar-web.js"], + input: ["src/common/ui/content/content-infobar-web.js"], output: [{ - file: "dist/web/infobar-web.js", + file: "lib/web/infobar-web.js", format: "iife", plugins: [terser()] }] }, { - input: ["extension/ui/content/content-ui-editor-init-web.js"], + input: ["src/extension/ui/content/content-ui-editor-init-web.js"], output: [{ - file: "dist/web/editor/editor-init-web.js", + file: "lib/web/editor/editor-init-web.js", format: "iife", plugins: [terser()] }] }, { - input: ["extension/ui/content/content-ui-editor-web.js"], + input: ["src/extension/ui/content/content-ui-editor-web.js"], output: [{ - file: "dist/web/editor/editor-web.js", + file: "lib/web/editor/editor-web.js", format: "iife", plugins: [] }] }, { - input: ["extension/ui/content/content-ui-editor-helper-web"], + input: ["src/extension/ui/content/content-ui-editor-helper-web"], output: [{ - file: "dist/web/editor/editor-helper-web.js", + file: "lib/web/editor/editor-helper-web.js", format: "umd", name: "singlefile", plugins: [terser()] }] }, { - input: ["extension/lib/single-file/browser-polyfill/chrome-browser-polyfill.js"], + input: ["src/extension/lib/single-file/browser-polyfill/chrome-browser-polyfill.js"], output: [{ - file: "dist/chrome-browser-polyfill.js", + file: "lib/chrome-browser-polyfill.js", format: "iife", plugins: [terser()] }] }, { - input: ["extension/core/bg/index.js"], + input: ["src/extension/core/bg/index.js"], output: [{ - file: "dist/extension-background.js", + file: "lib/extension-background.js", format: "iife", plugins: [terser()] }] }, { - input: ["extension/lib/single-file/background.js"], + input: ["src/extension/lib/single-file/background.js"], output: [{ - file: "dist/single-file-background.js", + file: "lib/single-file-background.js", format: "iife", plugins: [terser()] }] diff --git a/common/ui/content/content-infobar-web.js b/src/common/ui/content/content-infobar-web.js similarity index 100% rename from common/ui/content/content-infobar-web.js rename to src/common/ui/content/content-infobar-web.js diff --git a/common/ui/content/content-infobar.js b/src/common/ui/content/content-infobar.js similarity index 97% rename from common/ui/content/content-infobar.js rename to src/common/ui/content/content-infobar.js index 59e5e890e..2b8fd523b 100644 --- a/common/ui/content/content-infobar.js +++ b/src/common/ui/content/content-infobar.js @@ -23,7 +23,7 @@ /* global globalThis, singlefile, fetch */ -const SCRIPT_PATH = "/dist/web/infobar-web.js"; +const SCRIPT_PATH = "/lib/web/infobar-web.js"; const browser = globalThis.browser; diff --git a/extension/core/bg/autosave-util.js b/src/extension/core/bg/autosave-util.js similarity index 100% rename from extension/core/bg/autosave-util.js rename to src/extension/core/bg/autosave-util.js diff --git a/extension/core/bg/autosave.js b/src/extension/core/bg/autosave.js similarity index 100% rename from extension/core/bg/autosave.js rename to src/extension/core/bg/autosave.js diff --git a/src/extension/core/bg/background.html b/src/extension/core/bg/background.html new file mode 100644 index 000000000..f4030572b --- /dev/null +++ b/src/extension/core/bg/background.html @@ -0,0 +1,16 @@ + + + + + + Background page + + + + + + + + + + \ No newline at end of file diff --git a/extension/core/bg/bookmarks.js b/src/extension/core/bg/bookmarks.js similarity index 100% rename from extension/core/bg/bookmarks.js rename to src/extension/core/bg/bookmarks.js diff --git a/extension/core/bg/bootstrap.js b/src/extension/core/bg/bootstrap.js similarity index 100% rename from extension/core/bg/bootstrap.js rename to src/extension/core/bg/bootstrap.js diff --git a/extension/core/bg/business.js b/src/extension/core/bg/business.js similarity index 99% rename from extension/core/bg/business.js rename to src/extension/core/bg/business.js index d2b925fec..ecb31cdde 100644 --- a/extension/core/bg/business.js +++ b/src/extension/core/bg/business.js @@ -40,8 +40,8 @@ const TASK_PENDING_STATE = "pending"; const TASK_PROCESSING_STATE = "processing"; const extensionScriptFiles = [ - "dist/infobar.js", - "dist/extension.js" + "lib/infobar.js", + "lib/extension.js" ]; const tasks = []; diff --git a/extension/core/bg/companion.js b/src/extension/core/bg/companion.js similarity index 100% rename from extension/core/bg/companion.js rename to src/extension/core/bg/companion.js diff --git a/extension/core/bg/config.js b/src/extension/core/bg/config.js similarity index 100% rename from extension/core/bg/config.js rename to src/extension/core/bg/config.js diff --git a/extension/core/bg/devtools.js b/src/extension/core/bg/devtools.js similarity index 100% rename from extension/core/bg/devtools.js rename to src/extension/core/bg/devtools.js diff --git a/extension/core/bg/download-util.js b/src/extension/core/bg/download-util.js similarity index 100% rename from extension/core/bg/download-util.js rename to src/extension/core/bg/download-util.js diff --git a/extension/core/bg/downloads.js b/src/extension/core/bg/downloads.js similarity index 100% rename from extension/core/bg/downloads.js rename to src/extension/core/bg/downloads.js diff --git a/extension/core/bg/editor.js b/src/extension/core/bg/editor.js similarity index 98% rename from extension/core/bg/editor.js rename to src/extension/core/bg/editor.js index a57b377af..bfa1f1332 100644 --- a/extension/core/bg/editor.js +++ b/src/extension/core/bg/editor.js @@ -26,7 +26,7 @@ import * as config from "./config.js"; const MAX_CONTENT_SIZE = 32 * (1024 * 1024); -const EDITOR_PAGE_URL = "/extension/ui/pages/editor.html"; +const EDITOR_PAGE_URL = "/src/extension/ui/pages/editor.html"; const tabsData = new Map(); const partialContents = new Map(); const EDITOR_URL = browser.runtime.getURL(EDITOR_PAGE_URL); diff --git a/extension/core/bg/index.js b/src/extension/core/bg/index.js similarity index 100% rename from extension/core/bg/index.js rename to src/extension/core/bg/index.js diff --git a/extension/core/bg/requests.js b/src/extension/core/bg/requests.js similarity index 100% rename from extension/core/bg/requests.js rename to src/extension/core/bg/requests.js diff --git a/extension/core/bg/tabs-data.js b/src/extension/core/bg/tabs-data.js similarity index 100% rename from extension/core/bg/tabs-data.js rename to src/extension/core/bg/tabs-data.js diff --git a/extension/core/bg/tabs-util.js b/src/extension/core/bg/tabs-util.js similarity index 100% rename from extension/core/bg/tabs-util.js rename to src/extension/core/bg/tabs-util.js diff --git a/extension/core/bg/tabs.js b/src/extension/core/bg/tabs.js similarity index 100% rename from extension/core/bg/tabs.js rename to src/extension/core/bg/tabs.js diff --git a/extension/core/common/download.js b/src/extension/core/common/download.js similarity index 100% rename from extension/core/common/download.js rename to src/extension/core/common/download.js diff --git a/extension/core/content/content-bootstrap.js b/src/extension/core/content/content-bootstrap.js similarity index 100% rename from extension/core/content/content-bootstrap.js rename to src/extension/core/content/content-bootstrap.js diff --git a/extension/core/content/content-frames.js b/src/extension/core/content/content-frames.js similarity index 100% rename from extension/core/content/content-frames.js rename to src/extension/core/content/content-frames.js diff --git a/extension/core/content/content.js b/src/extension/core/content/content.js similarity index 100% rename from extension/core/content/content.js rename to src/extension/core/content/content.js diff --git a/extension/core/devtools/devtools.html b/src/extension/core/devtools/devtools.html similarity index 67% rename from extension/core/devtools/devtools.html rename to src/extension/core/devtools/devtools.html index aa3a55f0b..663e2a24a 100644 --- a/extension/core/devtools/devtools.html +++ b/src/extension/core/devtools/devtools.html @@ -6,7 +6,7 @@ - + diff --git a/extension/core/devtools/devtools.js b/src/extension/core/devtools/devtools.js similarity index 100% rename from extension/core/devtools/devtools.js rename to src/extension/core/devtools/devtools.js diff --git a/extension/index.js b/src/extension/index.js similarity index 100% rename from extension/index.js rename to src/extension/index.js diff --git a/extension/lib/gdrive/gdrive.js b/src/extension/lib/gdrive/gdrive.js similarity index 100% rename from extension/lib/gdrive/gdrive.js rename to src/extension/lib/gdrive/gdrive.js diff --git a/extension/lib/github/github.js b/src/extension/lib/github/github.js similarity index 100% rename from extension/lib/github/github.js rename to src/extension/lib/github/github.js diff --git a/extension/lib/readability/Readability-readerable.js b/src/extension/lib/readability/Readability-readerable.js similarity index 100% rename from extension/lib/readability/Readability-readerable.js rename to src/extension/lib/readability/Readability-readerable.js diff --git a/extension/lib/readability/Readability.js b/src/extension/lib/readability/Readability.js similarity index 100% rename from extension/lib/readability/Readability.js rename to src/extension/lib/readability/Readability.js diff --git a/extension/lib/single-file/background.js b/src/extension/lib/single-file/background.js similarity index 100% rename from extension/lib/single-file/background.js rename to src/extension/lib/single-file/background.js diff --git a/extension/lib/single-file/browser-polyfill/chrome-browser-polyfill.js b/src/extension/lib/single-file/browser-polyfill/chrome-browser-polyfill.js similarity index 100% rename from extension/lib/single-file/browser-polyfill/chrome-browser-polyfill.js rename to src/extension/lib/single-file/browser-polyfill/chrome-browser-polyfill.js diff --git a/extension/lib/single-file/core/bg/scripts.js b/src/extension/lib/single-file/core/bg/scripts.js similarity index 95% rename from extension/lib/single-file/core/bg/scripts.js rename to src/extension/lib/single-file/core/bg/scripts.js index 4a9ebd9bd..cf9524bdd 100644 --- a/extension/lib/single-file/core/bg/scripts.js +++ b/src/extension/lib/single-file/core/bg/scripts.js @@ -26,13 +26,13 @@ let contentScript, frameScript; const contentScriptFiles = [ - "dist/chrome-browser-polyfill.js", - "dist/single-file.js" + "lib/chrome-browser-polyfill.js", + "lib/single-file.js" ]; const frameScriptFiles = [ - "dist/chrome-browser-polyfill.js", - "dist/single-file-frames.js" + "lib/chrome-browser-polyfill.js", + "lib/single-file-frames.js" ]; const basePath = "../../../"; diff --git a/extension/lib/single-file/fetch/bg/fetch.js b/src/extension/lib/single-file/fetch/bg/fetch.js similarity index 100% rename from extension/lib/single-file/fetch/bg/fetch.js rename to src/extension/lib/single-file/fetch/bg/fetch.js diff --git a/extension/lib/single-file/fetch/content/content-fetch.js b/src/extension/lib/single-file/fetch/content/content-fetch.js similarity index 100% rename from extension/lib/single-file/fetch/content/content-fetch.js rename to src/extension/lib/single-file/fetch/content/content-fetch.js diff --git a/extension/lib/single-file/frame-tree/bg/frame-tree.js b/src/extension/lib/single-file/frame-tree/bg/frame-tree.js similarity index 100% rename from extension/lib/single-file/frame-tree/bg/frame-tree.js rename to src/extension/lib/single-file/frame-tree/bg/frame-tree.js diff --git a/extension/lib/single-file/lazy/bg/lazy-timeout.js b/src/extension/lib/single-file/lazy/bg/lazy-timeout.js similarity index 100% rename from extension/lib/single-file/lazy/bg/lazy-timeout.js rename to src/extension/lib/single-file/lazy/bg/lazy-timeout.js diff --git a/extension/ui/bg/index.js b/src/extension/ui/bg/index.js similarity index 100% rename from extension/ui/bg/index.js rename to src/extension/ui/bg/index.js diff --git a/extension/ui/bg/ui-button.js b/src/extension/ui/bg/ui-button.js similarity index 98% rename from extension/ui/bg/ui-button.js rename to src/extension/ui/bg/ui-button.js index 0b62de3d4..5fe534ad3 100644 --- a/extension/ui/bg/ui-button.js +++ b/src/extension/ui/bg/ui-button.js @@ -27,8 +27,8 @@ import { queryTabs } from "./../../core/bg/tabs-util.js"; import * as tabsData from "./../../core/bg/tabs-data.js"; import { autoSaveIsEnabled } from "../../core/bg/autosave-util.js"; -const DEFAULT_ICON_PATH = "/extension/ui/resources/icon_128.png"; -const WAIT_ICON_PATH_PREFIX = "/extension/ui/resources/icon_128_wait"; +const DEFAULT_ICON_PATH = "/src/extension/ui/resources/icon_128.png"; +const WAIT_ICON_PATH_PREFIX = "/src/extension/ui/resources/icon_128_wait"; const BUTTON_DEFAULT_TOOLTIP_MESSAGE = browser.i18n.getMessage("buttonDefaultTooltip"); const BUTTON_BLOCKED_TOOLTIP_MESSAGE = browser.i18n.getMessage("buttonBlockedTooltip"); const BUTTON_DEFAULT_BADGE_MESSAGE = ""; diff --git a/extension/ui/bg/ui-commands.js b/src/extension/ui/bg/ui-commands.js similarity index 100% rename from extension/ui/bg/ui-commands.js rename to src/extension/ui/bg/ui-commands.js diff --git a/extension/ui/bg/ui-editor.js b/src/extension/ui/bg/ui-editor.js similarity index 96% rename from extension/ui/bg/ui-editor.js rename to src/extension/ui/bg/ui-editor.js index a44bae84c..0894396a1 100644 --- a/extension/ui/bg/ui-editor.js +++ b/src/extension/ui/bg/ui-editor.js @@ -105,17 +105,17 @@ highlightButtons.forEach(highlightButton => { }; }); toggleNotesButton.onmouseup = () => { - if (toggleNotesButton.getAttribute("src") == "/extension/ui/resources/button_note_visible.png") { - toggleNotesButton.src = "/extension/ui/resources/button_note_hidden.png"; + if (toggleNotesButton.getAttribute("src") == "/src/extension/ui/resources/button_note_visible.png") { + toggleNotesButton.src = "/src/extension/ui/resources/button_note_hidden.png"; editorElement.contentWindow.postMessage(JSON.stringify({ method: "hideNotes" }), "*"); } else { - toggleNotesButton.src = "/extension/ui/resources/button_note_visible.png"; + toggleNotesButton.src = "/src/extension/ui/resources/button_note_visible.png"; editorElement.contentWindow.postMessage(JSON.stringify({ method: "displayNotes" }), "*"); } }; toggleHighlightsButton.onmouseup = () => { - if (toggleHighlightsButton.getAttribute("src") == "/extension/ui/resources/button_highlighter_visible.png") { - toggleHighlightsButton.src = "/extension/ui/resources/button_highlighter_hidden.png"; + if (toggleHighlightsButton.getAttribute("src") == "/src/extension/ui/resources/button_highlighter_visible.png") { + toggleHighlightsButton.src = "/src/extension/ui/resources/button_highlighter_hidden.png"; editorElement.contentWindow.postMessage(JSON.stringify({ method: "hideHighlights" }), "*"); } else { displayHighlights(); @@ -392,7 +392,7 @@ function disableRemoveHighlights() { } function displayHighlights() { - toggleHighlightsButton.src = "/extension/ui/resources/button_highlighter_visible.png"; + toggleHighlightsButton.src = "/src/extension/ui/resources/button_highlighter_visible.png"; editorElement.contentWindow.postMessage(JSON.stringify({ method: "displayHighlights" }), "*"); } diff --git a/extension/ui/bg/ui-menus.js b/src/extension/ui/bg/ui-menus.js similarity index 99% rename from extension/ui/bg/ui-menus.js rename to src/extension/ui/bg/ui-menus.js index 8ba9218b2..10b858b13 100644 --- a/extension/ui/bg/ui-menus.js +++ b/src/extension/ui/bg/ui-menus.js @@ -408,7 +408,7 @@ async function initialize() { business.saveSelectedLinks(tab); } if (event.menuItemId == MENU_ID_VIEW_PENDINGS) { - await browser.tabs.create({ active: true, url: "/extension/ui/pages/pendings.html" }); + await browser.tabs.create({ active: true, url: "/src/extension/ui/pages/pendings.html" }); } if (event.menuItemId == MENU_ID_SAVE_SELECTED) { business.saveTabs([tab], { selected: true }); diff --git a/extension/ui/bg/ui-options.js b/src/extension/ui/bg/ui-options.js similarity index 99% rename from extension/ui/bg/ui-options.js rename to src/extension/ui/bg/ui-options.js index f4c7fb347..fab7df1ec 100644 --- a/extension/ui/bg/ui-options.js +++ b/src/extension/ui/bg/ui-options.js @@ -24,7 +24,7 @@ /* global browser, window, document, localStorage, FileReader, location, fetch, TextDecoder, DOMParser, HTMLElement */ const HELP_ICON_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABIUlEQVQ4y+2TsarCMBSGvxTBRdqiUZAWOrhJB9EXcPKFfCvfQYfulUKHDqXg4CYUJSioYO4mSDX3ttzt3n87fMlHTpIjlsulxpDZbEYYhgghSNOUOI5Ny2mZYBAELBYLer0eAJ7ncTweKYri4x7LJJRS0u12n7XrukgpjSc0CpVSXK/XZ32/31FKNW85z3PW6zXT6RSAJEnIsqy5UGvNZrNhu90CcDqd+C6tT6J+v//2Th+PB2VZ1hN2Oh3G4zGTyQTbtl/YbrdjtVpxu91+Ljyfz0RRhG3bzOfzF+Y4TvNXvlwuaK2pE4tfzr/wzwsty0IIURlL0998KxRCMBqN8H2/wlzXJQxD2u12vVkeDoeUZUkURRU+GAw4HA7s9/sK+wK6CWHasQ/S/wAAAABJRU5ErkJggg=="; -const HELP_PAGE_PATH = "/extension/ui/pages/help.html"; +const HELP_PAGE_PATH = "/src/extension/ui/pages/help.html"; let DEFAULT_PROFILE_NAME, DISABLED_PROFILE_NAME, CURRENT_PROFILE_NAME; browser.runtime.sendMessage({ method: "config.getConstants" }).then(data => ({ DEFAULT_PROFILE_NAME, DISABLED_PROFILE_NAME, CURRENT_PROFILE_NAME } = data)); const removeHiddenElementsLabel = document.getElementById("removeHiddenElementsLabel"); diff --git a/extension/ui/bg/ui-panel.js b/src/extension/ui/bg/ui-panel.js similarity index 100% rename from extension/ui/bg/ui-panel.js rename to src/extension/ui/bg/ui-panel.js diff --git a/extension/ui/bg/ui-pendings.js b/src/extension/ui/bg/ui-pendings.js similarity index 100% rename from extension/ui/bg/ui-pendings.js rename to src/extension/ui/bg/ui-pendings.js diff --git a/extension/ui/common/content-error.js b/src/extension/ui/common/content-error.js similarity index 100% rename from extension/ui/common/content-error.js rename to src/extension/ui/common/content-error.js diff --git a/extension/ui/content/content-ui-editor-helper-web.js b/src/extension/ui/content/content-ui-editor-helper-web.js similarity index 93% rename from extension/ui/content/content-ui-editor-helper-web.js rename to src/extension/ui/content/content-ui-editor-helper-web.js index 72f2f9760..5ed38179e 100644 --- a/extension/ui/content/content-ui-editor-helper-web.js +++ b/src/extension/ui/content/content-ui-editor-helper-web.js @@ -21,7 +21,7 @@ * Source. */ -import * as serializer from "../../../lib/single-file/modules/html-serializer.js"; +import * as serializer from "../../../../src/single-file/modules/html-serializer.js"; const helper = { serialize(doc, compressHTML) { diff --git a/extension/ui/content/content-ui-editor-init-web.js b/src/extension/ui/content/content-ui-editor-init-web.js similarity index 100% rename from extension/ui/content/content-ui-editor-init-web.js rename to src/extension/ui/content/content-ui-editor-init-web.js diff --git a/extension/ui/content/content-ui-editor-web.js b/src/extension/ui/content/content-ui-editor-web.js similarity index 99% rename from extension/ui/content/content-ui-editor-web.js rename to src/extension/ui/content/content-ui-editor-web.js index 6985f31c1..fb57610b6 100644 --- a/extension/ui/content/content-ui-editor-web.js +++ b/src/extension/ui/content/content-ui-editor-web.js @@ -1003,7 +1003,7 @@ table { if (initScriptContentMatch && initScriptContentMatch[0]) { initScriptContent = initScriptContentMatch[0]; } - content = content.replace(/"); + content = content.replace(/"); const contentDocument = (new DOMParser()).parseFromString(content, "text/html"); if (detectSavedPage(contentDocument)) { if (contentDocument.doctype) { diff --git a/extension/ui/content/content-ui.js b/src/extension/ui/content/content-ui.js similarity index 100% rename from extension/ui/content/content-ui.js rename to src/extension/ui/content/content-ui.js diff --git a/extension/ui/pages/editor-frame-web.css b/src/extension/ui/pages/editor-frame-web.css similarity index 100% rename from extension/ui/pages/editor-frame-web.css rename to src/extension/ui/pages/editor-frame-web.css diff --git a/extension/ui/pages/editor-mask-web.css b/src/extension/ui/pages/editor-mask-web.css similarity index 100% rename from extension/ui/pages/editor-mask-web.css rename to src/extension/ui/pages/editor-mask-web.css diff --git a/extension/ui/pages/editor-note-web.css b/src/extension/ui/pages/editor-note-web.css similarity index 100% rename from extension/ui/pages/editor-note-web.css rename to src/extension/ui/pages/editor-note-web.css diff --git a/extension/ui/pages/editor.css b/src/extension/ui/pages/editor.css similarity index 100% rename from extension/ui/pages/editor.css rename to src/extension/ui/pages/editor.css diff --git a/src/extension/ui/pages/editor.html b/src/extension/ui/pages/editor.html new file mode 100644 index 000000000..6bf99b0de --- /dev/null +++ b/src/extension/ui/pages/editor.html @@ -0,0 +1,78 @@ + + + + + + + + +   + + + +
+
+ + + + + +
+
+
+ + + + + + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + +
+
+ + + + + + + + \ No newline at end of file diff --git a/extension/ui/pages/help.css b/src/extension/ui/pages/help.css similarity index 100% rename from extension/ui/pages/help.css rename to src/extension/ui/pages/help.css diff --git a/extension/ui/pages/help.html b/src/extension/ui/pages/help.html similarity index 100% rename from extension/ui/pages/help.html rename to src/extension/ui/pages/help.html diff --git a/extension/ui/pages/options.css b/src/extension/ui/pages/options.css similarity index 100% rename from extension/ui/pages/options.css rename to src/extension/ui/pages/options.css diff --git a/extension/ui/pages/options.html b/src/extension/ui/pages/options.html similarity index 99% rename from extension/ui/pages/options.html rename to src/extension/ui/pages/options.html index e240f6ae2..554fc4ed9 100644 --- a/extension/ui/pages/options.html +++ b/src/extension/ui/pages/options.html @@ -449,7 +449,7 @@

- + diff --git a/extension/ui/pages/panel.css b/src/extension/ui/pages/panel.css similarity index 100% rename from extension/ui/pages/panel.css rename to src/extension/ui/pages/panel.css diff --git a/extension/ui/pages/panel.html b/src/extension/ui/pages/panel.html similarity index 100% rename from extension/ui/pages/panel.html rename to src/extension/ui/pages/panel.html diff --git a/extension/ui/pages/pendings.css b/src/extension/ui/pages/pendings.css similarity index 100% rename from extension/ui/pages/pendings.css rename to src/extension/ui/pages/pendings.css diff --git a/extension/ui/pages/pendings.html b/src/extension/ui/pages/pendings.html similarity index 95% rename from extension/ui/pages/pendings.html rename to src/extension/ui/pages/pendings.html index 61f598956..a77c4c70e 100644 --- a/extension/ui/pages/pendings.html +++ b/src/extension/ui/pages/pendings.html @@ -39,7 +39,7 @@ - + diff --git a/extension/ui/resources/button_cut_inner.png b/src/extension/ui/resources/button_cut_inner.png similarity index 100% rename from extension/ui/resources/button_cut_inner.png rename to src/extension/ui/resources/button_cut_inner.png diff --git a/extension/ui/resources/button_cut_outer.png b/src/extension/ui/resources/button_cut_outer.png similarity index 100% rename from extension/ui/resources/button_cut_outer.png rename to src/extension/ui/resources/button_cut_outer.png diff --git a/extension/ui/resources/button_delete.png b/src/extension/ui/resources/button_delete.png similarity index 100% rename from extension/ui/resources/button_delete.png rename to src/extension/ui/resources/button_delete.png diff --git a/extension/ui/resources/button_delete_all.png b/src/extension/ui/resources/button_delete_all.png similarity index 100% rename from extension/ui/resources/button_delete_all.png rename to src/extension/ui/resources/button_delete_all.png diff --git a/extension/ui/resources/button_download.png b/src/extension/ui/resources/button_download.png similarity index 100% rename from extension/ui/resources/button_download.png rename to src/extension/ui/resources/button_download.png diff --git a/extension/ui/resources/button_edit.png b/src/extension/ui/resources/button_edit.png similarity index 100% rename from extension/ui/resources/button_edit.png rename to src/extension/ui/resources/button_edit.png diff --git a/extension/ui/resources/button_highlighter_blue.png b/src/extension/ui/resources/button_highlighter_blue.png similarity index 100% rename from extension/ui/resources/button_highlighter_blue.png rename to src/extension/ui/resources/button_highlighter_blue.png diff --git a/extension/ui/resources/button_highlighter_delete.png b/src/extension/ui/resources/button_highlighter_delete.png similarity index 100% rename from extension/ui/resources/button_highlighter_delete.png rename to src/extension/ui/resources/button_highlighter_delete.png diff --git a/extension/ui/resources/button_highlighter_green.png b/src/extension/ui/resources/button_highlighter_green.png similarity index 100% rename from extension/ui/resources/button_highlighter_green.png rename to src/extension/ui/resources/button_highlighter_green.png diff --git a/extension/ui/resources/button_highlighter_hidden.png b/src/extension/ui/resources/button_highlighter_hidden.png similarity index 100% rename from extension/ui/resources/button_highlighter_hidden.png rename to src/extension/ui/resources/button_highlighter_hidden.png diff --git a/extension/ui/resources/button_highlighter_pink.png b/src/extension/ui/resources/button_highlighter_pink.png similarity index 100% rename from extension/ui/resources/button_highlighter_pink.png rename to src/extension/ui/resources/button_highlighter_pink.png diff --git a/extension/ui/resources/button_highlighter_visible.png b/src/extension/ui/resources/button_highlighter_visible.png similarity index 100% rename from extension/ui/resources/button_highlighter_visible.png rename to src/extension/ui/resources/button_highlighter_visible.png diff --git a/extension/ui/resources/button_highlighter_yellow.png b/src/extension/ui/resources/button_highlighter_yellow.png similarity index 100% rename from extension/ui/resources/button_highlighter_yellow.png rename to src/extension/ui/resources/button_highlighter_yellow.png diff --git a/extension/ui/resources/button_new.png b/src/extension/ui/resources/button_new.png similarity index 100% rename from extension/ui/resources/button_new.png rename to src/extension/ui/resources/button_new.png diff --git a/extension/ui/resources/button_note_blue.png b/src/extension/ui/resources/button_note_blue.png similarity index 100% rename from extension/ui/resources/button_note_blue.png rename to src/extension/ui/resources/button_note_blue.png diff --git a/extension/ui/resources/button_note_edit.png b/src/extension/ui/resources/button_note_edit.png similarity index 100% rename from extension/ui/resources/button_note_edit.png rename to src/extension/ui/resources/button_note_edit.png diff --git a/extension/ui/resources/button_note_format.png b/src/extension/ui/resources/button_note_format.png similarity index 100% rename from extension/ui/resources/button_note_format.png rename to src/extension/ui/resources/button_note_format.png diff --git a/extension/ui/resources/button_note_green.png b/src/extension/ui/resources/button_note_green.png similarity index 100% rename from extension/ui/resources/button_note_green.png rename to src/extension/ui/resources/button_note_green.png diff --git a/extension/ui/resources/button_note_hidden.png b/src/extension/ui/resources/button_note_hidden.png similarity index 100% rename from extension/ui/resources/button_note_hidden.png rename to src/extension/ui/resources/button_note_hidden.png diff --git a/extension/ui/resources/button_note_pink.png b/src/extension/ui/resources/button_note_pink.png similarity index 100% rename from extension/ui/resources/button_note_pink.png rename to src/extension/ui/resources/button_note_pink.png diff --git a/extension/ui/resources/button_note_visible.png b/src/extension/ui/resources/button_note_visible.png similarity index 100% rename from extension/ui/resources/button_note_visible.png rename to src/extension/ui/resources/button_note_visible.png diff --git a/extension/ui/resources/button_note_yellow.png b/src/extension/ui/resources/button_note_yellow.png similarity index 100% rename from extension/ui/resources/button_note_yellow.png rename to src/extension/ui/resources/button_note_yellow.png diff --git a/extension/ui/resources/button_ok.png b/src/extension/ui/resources/button_ok.png similarity index 100% rename from extension/ui/resources/button_ok.png rename to src/extension/ui/resources/button_ok.png diff --git a/extension/ui/resources/button_print.png b/src/extension/ui/resources/button_print.png similarity index 100% rename from extension/ui/resources/button_print.png rename to src/extension/ui/resources/button_print.png diff --git a/extension/ui/resources/button_redo_cut.png b/src/extension/ui/resources/button_redo_cut.png similarity index 100% rename from extension/ui/resources/button_redo_cut.png rename to src/extension/ui/resources/button_redo_cut.png diff --git a/extension/ui/resources/button_undo_all_cut.png b/src/extension/ui/resources/button_undo_all_cut.png similarity index 100% rename from extension/ui/resources/button_undo_all_cut.png rename to src/extension/ui/resources/button_undo_all_cut.png diff --git a/extension/ui/resources/button_undo_cut.png b/src/extension/ui/resources/button_undo_cut.png similarity index 100% rename from extension/ui/resources/button_undo_cut.png rename to src/extension/ui/resources/button_undo_cut.png diff --git a/extension/ui/resources/icon_128.png b/src/extension/ui/resources/icon_128.png similarity index 100% rename from extension/ui/resources/icon_128.png rename to src/extension/ui/resources/icon_128.png diff --git a/extension/ui/resources/icon_128_wait0.png b/src/extension/ui/resources/icon_128_wait0.png similarity index 100% rename from extension/ui/resources/icon_128_wait0.png rename to src/extension/ui/resources/icon_128_wait0.png diff --git a/extension/ui/resources/icon_128_wait1.png b/src/extension/ui/resources/icon_128_wait1.png similarity index 100% rename from extension/ui/resources/icon_128_wait1.png rename to src/extension/ui/resources/icon_128_wait1.png diff --git a/extension/ui/resources/icon_128_wait2.png b/src/extension/ui/resources/icon_128_wait2.png similarity index 100% rename from extension/ui/resources/icon_128_wait2.png rename to src/extension/ui/resources/icon_128_wait2.png diff --git a/extension/ui/resources/icon_128_wait3.png b/src/extension/ui/resources/icon_128_wait3.png similarity index 100% rename from extension/ui/resources/icon_128_wait3.png rename to src/extension/ui/resources/icon_128_wait3.png diff --git a/extension/ui/resources/icon_128_wait4.png b/src/extension/ui/resources/icon_128_wait4.png similarity index 100% rename from extension/ui/resources/icon_128_wait4.png rename to src/extension/ui/resources/icon_128_wait4.png diff --git a/extension/ui/resources/icon_128_wait5.png b/src/extension/ui/resources/icon_128_wait5.png similarity index 100% rename from extension/ui/resources/icon_128_wait5.png rename to src/extension/ui/resources/icon_128_wait5.png diff --git a/extension/ui/resources/icon_128_wait6.png b/src/extension/ui/resources/icon_128_wait6.png similarity index 100% rename from extension/ui/resources/icon_128_wait6.png rename to src/extension/ui/resources/icon_128_wait6.png diff --git a/extension/ui/resources/icon_128_wait7.png b/src/extension/ui/resources/icon_128_wait7.png similarity index 100% rename from extension/ui/resources/icon_128_wait7.png rename to src/extension/ui/resources/icon_128_wait7.png diff --git a/extension/ui/resources/icon_128_wait8.png b/src/extension/ui/resources/icon_128_wait8.png similarity index 100% rename from extension/ui/resources/icon_128_wait8.png rename to src/extension/ui/resources/icon_128_wait8.png diff --git a/extension/ui/resources/icon_16.png b/src/extension/ui/resources/icon_16.png similarity index 100% rename from extension/ui/resources/icon_16.png rename to src/extension/ui/resources/icon_16.png diff --git a/extension/ui/resources/icon_48.png b/src/extension/ui/resources/icon_48.png similarity index 100% rename from extension/ui/resources/icon_48.png rename to src/extension/ui/resources/icon_48.png diff --git a/extension/ui/resources/icon_64.png b/src/extension/ui/resources/icon_64.png similarity index 100% rename from extension/ui/resources/icon_64.png rename to src/extension/ui/resources/icon_64.png diff --git a/lib/single-file/index.js b/src/single-file/index.js similarity index 100% rename from lib/single-file/index.js rename to src/single-file/index.js diff --git a/lib/single-file/modules/css-fonts-alt-minifier.js b/src/single-file/modules/css-fonts-alt-minifier.js similarity index 100% rename from lib/single-file/modules/css-fonts-alt-minifier.js rename to src/single-file/modules/css-fonts-alt-minifier.js diff --git a/lib/single-file/modules/css-fonts-minifier.js b/src/single-file/modules/css-fonts-minifier.js similarity index 100% rename from lib/single-file/modules/css-fonts-minifier.js rename to src/single-file/modules/css-fonts-minifier.js diff --git a/lib/single-file/modules/css-matched-rules.js b/src/single-file/modules/css-matched-rules.js similarity index 100% rename from lib/single-file/modules/css-matched-rules.js rename to src/single-file/modules/css-matched-rules.js diff --git a/lib/single-file/modules/css-medias-alt-minifier.js b/src/single-file/modules/css-medias-alt-minifier.js similarity index 100% rename from lib/single-file/modules/css-medias-alt-minifier.js rename to src/single-file/modules/css-medias-alt-minifier.js diff --git a/lib/single-file/modules/css-rules-minifier.js b/src/single-file/modules/css-rules-minifier.js similarity index 100% rename from lib/single-file/modules/css-rules-minifier.js rename to src/single-file/modules/css-rules-minifier.js diff --git a/lib/single-file/modules/html-images-alt-minifier.js b/src/single-file/modules/html-images-alt-minifier.js similarity index 100% rename from lib/single-file/modules/html-images-alt-minifier.js rename to src/single-file/modules/html-images-alt-minifier.js diff --git a/lib/single-file/modules/html-minifier.js b/src/single-file/modules/html-minifier.js similarity index 100% rename from lib/single-file/modules/html-minifier.js rename to src/single-file/modules/html-minifier.js diff --git a/lib/single-file/modules/html-serializer.js b/src/single-file/modules/html-serializer.js similarity index 100% rename from lib/single-file/modules/html-serializer.js rename to src/single-file/modules/html-serializer.js diff --git a/lib/single-file/modules/index.js b/src/single-file/modules/index.js similarity index 100% rename from lib/single-file/modules/index.js rename to src/single-file/modules/index.js diff --git a/lib/single-file/processors/frame-tree/content/content-frame-tree.js b/src/single-file/processors/frame-tree/content/content-frame-tree.js similarity index 100% rename from lib/single-file/processors/frame-tree/content/content-frame-tree.js rename to src/single-file/processors/frame-tree/content/content-frame-tree.js diff --git a/lib/single-file/processors/hooks/content/content-hooks-frames-web.js b/src/single-file/processors/hooks/content/content-hooks-frames-web.js similarity index 100% rename from lib/single-file/processors/hooks/content/content-hooks-frames-web.js rename to src/single-file/processors/hooks/content/content-hooks-frames-web.js diff --git a/lib/single-file/processors/hooks/content/content-hooks-frames.js b/src/single-file/processors/hooks/content/content-hooks-frames.js similarity index 98% rename from lib/single-file/processors/hooks/content/content-hooks-frames.js rename to src/single-file/processors/hooks/content/content-hooks-frames.js index 20283b147..9cbbe62f0 100644 --- a/lib/single-file/processors/hooks/content/content-hooks-frames.js +++ b/src/single-file/processors/hooks/content/content-hooks-frames.js @@ -73,7 +73,7 @@ if (document instanceof Document) { (document.documentElement || document).appendChild(scriptElement); scriptElement.remove(); scriptElement = document.createElement("script"); - scriptElement.src = browser.runtime.getURL("/dist/web/hooks/hooks-frames-web.js"); + scriptElement.src = browser.runtime.getURL("/lib/web/hooks/hooks-frames-web.js"); scriptElement.async = false; (document.documentElement || document).appendChild(scriptElement); scriptElement.remove(); diff --git a/lib/single-file/processors/hooks/content/content-hooks-web.js b/src/single-file/processors/hooks/content/content-hooks-web.js similarity index 100% rename from lib/single-file/processors/hooks/content/content-hooks-web.js rename to src/single-file/processors/hooks/content/content-hooks-web.js diff --git a/lib/single-file/processors/hooks/content/content-hooks.js b/src/single-file/processors/hooks/content/content-hooks.js similarity index 94% rename from lib/single-file/processors/hooks/content/content-hooks.js rename to src/single-file/processors/hooks/content/content-hooks.js index d55d5fca9..ddbd5f9bc 100644 --- a/lib/single-file/processors/hooks/content/content-hooks.js +++ b/src/single-file/processors/hooks/content/content-hooks.js @@ -31,7 +31,7 @@ if (document instanceof Document) { const scriptElement = document.createElement("script"); scriptElement.async = false; if (browser && browser.runtime && browser.runtime.getURL) { - scriptElement.src = browser.runtime.getURL("/dist/web/hooks/hooks-web.js"); + scriptElement.src = browser.runtime.getURL("/lib/web/hooks/hooks-web.js"); scriptElement.async = false; } (document.documentElement || document).appendChild(scriptElement); diff --git a/lib/single-file/processors/index.js b/src/single-file/processors/index.js similarity index 100% rename from lib/single-file/processors/index.js rename to src/single-file/processors/index.js diff --git a/lib/single-file/processors/lazy/content/content-lazy-loader.js b/src/single-file/processors/lazy/content/content-lazy-loader.js similarity index 100% rename from lib/single-file/processors/lazy/content/content-lazy-loader.js rename to src/single-file/processors/lazy/content/content-lazy-loader.js diff --git a/lib/single-file/single-file-bootstrap.js b/src/single-file/single-file-bootstrap.js similarity index 100% rename from lib/single-file/single-file-bootstrap.js rename to src/single-file/single-file-bootstrap.js diff --git a/lib/single-file/single-file-core.js b/src/single-file/single-file-core.js similarity index 100% rename from lib/single-file/single-file-core.js rename to src/single-file/single-file-core.js diff --git a/lib/single-file/single-file-frames.js b/src/single-file/single-file-frames.js similarity index 100% rename from lib/single-file/single-file-frames.js rename to src/single-file/single-file-frames.js diff --git a/lib/single-file/single-file-helper.js b/src/single-file/single-file-helper.js similarity index 100% rename from lib/single-file/single-file-helper.js rename to src/single-file/single-file-helper.js diff --git a/lib/single-file/single-file-util.js b/src/single-file/single-file-util.js similarity index 100% rename from lib/single-file/single-file-util.js rename to src/single-file/single-file-util.js diff --git a/lib/single-file/vendor/css-font-property-parser.js b/src/single-file/vendor/css-font-property-parser.js similarity index 100% rename from lib/single-file/vendor/css-font-property-parser.js rename to src/single-file/vendor/css-font-property-parser.js diff --git a/lib/single-file/vendor/css-media-query-parser.js b/src/single-file/vendor/css-media-query-parser.js similarity index 100% rename from lib/single-file/vendor/css-media-query-parser.js rename to src/single-file/vendor/css-media-query-parser.js diff --git a/lib/single-file/vendor/css-minifier.js b/src/single-file/vendor/css-minifier.js similarity index 100% rename from lib/single-file/vendor/css-minifier.js rename to src/single-file/vendor/css-minifier.js diff --git a/lib/single-file/vendor/css-tree.js b/src/single-file/vendor/css-tree.js similarity index 100% rename from lib/single-file/vendor/css-tree.js rename to src/single-file/vendor/css-tree.js diff --git a/lib/single-file/vendor/css-unescape.js b/src/single-file/vendor/css-unescape.js similarity index 100% rename from lib/single-file/vendor/css-unescape.js rename to src/single-file/vendor/css-unescape.js diff --git a/lib/single-file/vendor/html-srcset-parser.js b/src/single-file/vendor/html-srcset-parser.js similarity index 100% rename from lib/single-file/vendor/html-srcset-parser.js rename to src/single-file/vendor/html-srcset-parser.js diff --git a/lib/single-file/vendor/index.js b/src/single-file/vendor/index.js similarity index 100% rename from lib/single-file/vendor/index.js rename to src/single-file/vendor/index.js diff --git a/lib/single-file/vendor/mime-type-parser.js b/src/single-file/vendor/mime-type-parser.js similarity index 100% rename from lib/single-file/vendor/mime-type-parser.js rename to src/single-file/vendor/mime-type-parser.js