From fafb5660aef253a05c48acb42c6ef6cbac9fa83c Mon Sep 17 00:00:00 2001 From: Gildas Date: Mon, 1 Jun 2020 20:36:55 +0200 Subject: [PATCH 01/22] updated Japanese translation --- _locales/ja/messages.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/_locales/ja/messages.json b/_locales/ja/messages.json index 1355af09c..14e5ff591 100644 --- a/_locales/ja/messages.json +++ b/_locales/ja/messages.json @@ -172,7 +172,7 @@ "description": "Options page label: 'template'" }, "optionFilenameMaxLength": { - "message": "max length (bytes)", + "message": "最大長(バイト)", "description": "Options page label: 'max length (bytes)'" }, "optionConfirmFilename": { @@ -196,10 +196,10 @@ "description": "Value for 'name conflict resolution' option: 'prompt for a name'" }, "optionFilenameConflictActionSkip": { - "message": "skip duplicate files", - "description": "Value for 'filename conflict resolution' option: 'skip duplicate files'" - }, - "optionsHTMLContentSubTitle": { + "message": "重複ファイルをスキップ", + "description": "Value for 'filename conflict resolution' option: 'skip duplicate files'" + }, + "optionsHTMLContentSubTitle": { "message": "HTML コンテンツ", "description": "Options sub-title: 'HTML content'" }, @@ -376,7 +376,7 @@ "description": "Options page label: 'save pages in background'" }, "optionApplySystemTheme": { - "message": "apply the system theme when formatting a page in the annotation editor", + "message": "(注釈エディタ)でページをフォーマットするときにシステムテーマを適用する", "description": "Title of the button 'apply the system theme when formatting a page in the annotation editor" }, "optionDisplayStats": { @@ -416,7 +416,7 @@ "description": "Options page label: 'save the page of a newly created bookmark'" }, "optionReplaceBookmarkURL": { - "message": "link the new bookmark to the saved page", + "message": "新しいブックマークを保存したページにリンクさせることを可能にする", "description": "Options page label: 'link the new bookmark to the saved page'" }, "optionsHelpLink": { @@ -631,4 +631,4 @@ "message": "Cancel", "description": "Add URLs popup cancel button: 'Cancel'" } -} +} \ No newline at end of file From 15fdb4eb812a9a5ba947e21076ca1a3389ea88a2 Mon Sep 17 00:00:00 2001 From: Gildas Date: Mon, 1 Jun 2020 21:14:21 +0200 Subject: [PATCH 02/22] bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index a06793ed8..edb06abbf 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "64": "extension/ui/resources/icon_64.png", "128": "extension/ui/resources/icon_128.png" }, - "version": "1.17.44", + "version": "1.17.45", "description": "__MSG_extensionDescription__", "content_scripts": [ { From 618202f51628a9697d2fc99e786f6a094ce825cd Mon Sep 17 00:00:00 2001 From: Gildas Date: Wed, 3 Jun 2020 23:13:35 +0200 Subject: [PATCH 03/22] fixed freeze issue (cf #428) --- extension/ui/content/content-ui-main.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/extension/ui/content/content-ui-main.js b/extension/ui/content/content-ui-main.js index 15b342af2..ca00185f3 100644 --- a/extension/ui/content/content-ui-main.js +++ b/extension/ui/content/content-ui-main.js @@ -58,8 +58,8 @@ this.singlefile.extension.ui.content.main = this.singlefile.extension.ui.content let maskElement = document.querySelector(MASK_TAGNAME); if (!maskElement) { if (options.logsEnabled) { - document.body.appendChild(logsWindowElement); setLogsWindowStyle(); + document.body.appendChild(logsWindowElement); } if (options.shadowEnabled) { const maskElement = createMaskElement(); @@ -378,10 +378,9 @@ this.singlefile.extension.ui.content.main = this.singlefile.extension.ui.content function createMaskElement() { let maskElement = document.querySelector(MASK_TAGNAME); if (!maskElement) { - maskElement = createElement(MASK_TAGNAME, document.body); + maskElement = createElement(MASK_TAGNAME); maskElement.style.setProperty("opacity", 0, "important"); maskElement.style.setProperty("background-color", "transparent", "important"); - maskElement.offsetWidth; maskElement.style.setProperty("position", "fixed", "important"); maskElement.style.setProperty("top", "0", "important"); maskElement.style.setProperty("left", "0", "important"); @@ -389,6 +388,8 @@ this.singlefile.extension.ui.content.main = this.singlefile.extension.ui.content maskElement.style.setProperty("height", "100%", "important"); maskElement.style.setProperty("z-index", 2147483646, "important"); maskElement.style.setProperty("transition", "opacity 250ms", "important"); + document.body.appendChild(maskElement); + maskElement.offsetWidth; } return maskElement; } @@ -529,7 +530,9 @@ this.singlefile.extension.ui.content.main = this.singlefile.extension.ui.content function createElement(tagName, parentElement) { const element = document.createElement(tagName); element.className = SINGLE_FILE_UI_ELEMENT_CLASS; - parentElement.appendChild(element); + if (parentElement) { + parentElement.appendChild(element); + } initStyle(element); return element; } From 584706c6a4e6953513f08f9bf41c23f5f2e247f0 Mon Sep 17 00:00:00 2001 From: Gildas Date: Wed, 3 Jun 2020 23:30:40 +0200 Subject: [PATCH 04/22] bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index edb06abbf..436bdf170 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "64": "extension/ui/resources/icon_64.png", "128": "extension/ui/resources/icon_128.png" }, - "version": "1.17.45", + "version": "1.17.46", "description": "__MSG_extensionDescription__", "content_scripts": [ { From 789f388abe2dc5d18ebb72f90c22b86c4ecfe25d Mon Sep 17 00:00:00 2001 From: Gildas Date: Thu, 4 Jun 2020 22:42:10 +0200 Subject: [PATCH 05/22] ignore SVG tags (fixes #429) --- lib/single-file/modules/html-serializer.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/single-file/modules/html-serializer.js b/lib/single-file/modules/html-serializer.js index 3021fb96e..ba0280957 100644 --- a/lib/single-file/modules/html-serializer.js +++ b/lib/single-file/modules/html-serializer.js @@ -77,13 +77,13 @@ this.singlefile.lib.modules.serializer = this.singlefile.lib.modules.serializer } }; - function serialize(node, compressHTML) { + function serialize(node, compressHTML, isSVG) { if (node.nodeType == Node_TEXT_NODE) { return serializeTextNode(node); } else if (node.nodeType == Node_COMMENT_NODE) { return serializeCommentNode(node); } else if (node.nodeType == Node_ELEMENT_NODE) { - return serializeElement(node, compressHTML); + return serializeElement(node, compressHTML, isSVG); } } @@ -107,7 +107,7 @@ this.singlefile.lib.modules.serializer = this.singlefile.lib.modules.serializer return ""; } - function serializeElement(element, compressHTML) { + function serializeElement(element, compressHTML, isSVG) { const tagName = element.tagName.toLowerCase(); const omittedStartTag = compressHTML && OMITTED_START_TAGS.find(omittedStartTag => tagName == omittedStartTag.tagName && omittedStartTag.accept(element)); let content = ""; @@ -119,10 +119,10 @@ this.singlefile.lib.modules.serializer = this.singlefile.lib.modules.serializer if (element.tagName == "TEMPLATE" && !element.childNodes.length) { content += element.innerHTML; } else { - Array.from(element.childNodes).forEach(childNode => content += serialize(childNode, compressHTML)); + Array.from(element.childNodes).forEach(childNode => content += serialize(childNode, compressHTML, isSVG || tagName == "svg")); } const omittedEndTag = compressHTML && OMITTED_END_TAGS.find(omittedEndTag => tagName == omittedEndTag.tagName && omittedEndTag.accept(element.nextSibling, element)); - if (!omittedEndTag && !SELF_CLOSED_TAG_NAMES.includes(tagName)) { + if (isSVG || (!omittedEndTag && !SELF_CLOSED_TAG_NAMES.includes(tagName))) { content += ""; } return content; From f5abc11c899700b5bfba3d7d0ad6a409632d21e4 Mon Sep 17 00:00:00 2001 From: Gildas Date: Thu, 4 Jun 2020 22:45:48 +0200 Subject: [PATCH 06/22] bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 436bdf170..49726ac44 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "64": "extension/ui/resources/icon_64.png", "128": "extension/ui/resources/icon_128.png" }, - "version": "1.17.46", + "version": "1.17.47", "description": "__MSG_extensionDescription__", "content_scripts": [ { From 1486e5b10c64a37ce9d78c668cbf1c425f08c5ab Mon Sep 17 00:00:00 2001 From: Gildas Date: Thu, 11 Jun 2020 21:55:53 +0200 Subject: [PATCH 07/22] pass frameId instead of windowId --- lib/single-file/single-file-core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/single-file/single-file-core.js b/lib/single-file/single-file-core.js index aa85fc7e5..7ca4bb1bb 100644 --- a/lib/single-file/single-file-core.js +++ b/lib/single-file/single-file-core.js @@ -1526,7 +1526,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => { maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled, validateTextContentType: true, - frameId: options.windowId + frameId: options.frameId }); resourceURL = content.resourceURL; content.data = getUpdatedResourceContent(resourceURL, content, options); @@ -1596,7 +1596,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => { maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled, charset: options.charset, - frameId: options.windowId, + frameId: options.frameId, validateTextContentType: true }); resourceURL = content.resourceURL; From 7cbccea7083415a71b00633e82dbaabd7fb3be10 Mon Sep 17 00:00:00 2001 From: Gildas Date: Thu, 11 Jun 2020 22:00:26 +0200 Subject: [PATCH 08/22] bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 49726ac44..d05f7aba7 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "64": "extension/ui/resources/icon_64.png", "128": "extension/ui/resources/icon_128.png" }, - "version": "1.17.47", + "version": "1.17.48", "description": "__MSG_extensionDescription__", "content_scripts": [ { From a9190d1499a85d9fdbad231d8ebeffc5bb7f5f33 Mon Sep 17 00:00:00 2001 From: Gildas Date: Wed, 17 Jun 2020 15:31:11 +0200 Subject: [PATCH 09/22] updated Chinese translation (cf #432) --- _locales/zh_CN/messages.json | 2 +- _locales/zh_TW/messages.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index 6a9d10f91..1309c61f8 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -196,7 +196,7 @@ "description": "Value for 'name conflict resolution' option: 'prompt for a name'" }, "optionFilenameConflictActionSkip": { - "message": "skip duplicate files", + "message": "跳过重复文件", "description": "Value for 'filename conflict resolution' option: 'skip duplicate files'" }, "optionsHTMLContentSubTitle": { diff --git a/_locales/zh_TW/messages.json b/_locales/zh_TW/messages.json index 3a43caaf1..17c421804 100644 --- a/_locales/zh_TW/messages.json +++ b/_locales/zh_TW/messages.json @@ -196,7 +196,7 @@ "description": "Value for 'name conflict resolution' option: 'prompt for a name'" }, "optionFilenameConflictActionSkip": { - "message": "skip duplicate files", + "message": "跳過重複文件", "description": "Value for 'filename conflict resolution' option: 'skip duplicate files'" }, "optionsHTMLContentSubTitle": { From 92dcb5a8fa314fd8359b9b2cf2a0c622af195716 Mon Sep 17 00:00:00 2001 From: Gildas Date: Wed, 17 Jun 2020 15:32:12 +0200 Subject: [PATCH 10/22] bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index d05f7aba7..6ff3c146c 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "64": "extension/ui/resources/icon_64.png", "128": "extension/ui/resources/icon_128.png" }, - "version": "1.17.48", + "version": "1.17.49", "description": "__MSG_extensionDescription__", "content_scripts": [ { From 7cb64a85c1db0939a39a3a895f0bddd82bc7c2f7 Mon Sep 17 00:00:00 2001 From: Gildas Date: Tue, 23 Jun 2020 23:20:36 +0200 Subject: [PATCH 11/22] fix issue when autosave is enabled and duplicates are skipped --- extension/core/bg/downloads.js | 72 +++++++++++++++++----------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/extension/core/bg/downloads.js b/extension/core/bg/downloads.js index 291c0a483..9540cf913 100644 --- a/extension/core/bg/downloads.js +++ b/extension/core/bg/downloads.js @@ -141,27 +141,12 @@ singlefile.extension.core.bg.downloads = (() => { }); } else { message.url = URL.createObjectURL(blob); - const filenameConflictAction = message.filenameConflictAction; - let skipped; - if (filenameConflictAction == CONFLICT_ACTION_SKIP) { - const downloadItems = await browser.downloads.search({ - filenameRegex: "(\\\\|/)" + getRegExp(message.filename) + "$", - exists: true - }); - if (downloadItems.length) { - skipped = true; - } else { - message.filenameConflictAction = CONFLICT_ACTION_UNIQUIFY; - } - } - if (!skipped) { - await downloadPage(message, { - confirmFilename: message.confirmFilename, - incognito, - filenameConflictAction: message.filenameConflictAction, - filenameReplacementCharacter: message.filenameReplacementCharacter - }); - } + await downloadPage(message, { + confirmFilename: message.confirmFilename, + incognito, + filenameConflictAction: message.filenameConflictAction, + filenameReplacementCharacter: message.filenameReplacementCharacter + }); } singlefile.extension.ui.bg.main.onEnd(tabId); } catch (error) { @@ -238,24 +223,39 @@ singlefile.extension.core.bg.downloads = (() => { } async function downloadPage(pageData, options) { - const downloadInfo = { - url: pageData.url, - saveAs: options.confirmFilename, - filename: pageData.filename, - conflictAction: options.filenameConflictAction - }; - if (options.incognito) { - downloadInfo.incognito = true; + const filenameConflictAction = options.filenameConflictAction; + let skipped; + if (filenameConflictAction == CONFLICT_ACTION_SKIP) { + const downloadItems = await browser.downloads.search({ + filenameRegex: "(\\\\|/)" + getRegExp(pageData.filename) + "$", + exists: true + }); + if (downloadItems.length) { + skipped = true; + } else { + options.filenameConflictAction = CONFLICT_ACTION_UNIQUIFY; + } } - const downloadData = await download(downloadInfo, options.filenameReplacementCharacter); - if (downloadData.filename && pageData.bookmarkId && pageData.replaceBookmarkURL) { - if (!downloadData.filename.startsWith("file:")) { - if (downloadData.filename.startsWith("/")) { - downloadData.filename = downloadData.filename.substring(1); + if (!skipped) { + const downloadInfo = { + url: pageData.url, + saveAs: options.confirmFilename, + filename: pageData.filename, + conflictAction: options.filenameConflictAction + }; + if (options.incognito) { + downloadInfo.incognito = true; + } + const downloadData = await download(downloadInfo, options.filenameReplacementCharacter); + if (downloadData.filename && pageData.bookmarkId && pageData.replaceBookmarkURL) { + if (!downloadData.filename.startsWith("file:")) { + if (downloadData.filename.startsWith("/")) { + downloadData.filename = downloadData.filename.substring(1); + } + downloadData.filename = "file:///" + downloadData.filename; } - downloadData.filename = "file:///" + downloadData.filename; + await singlefile.extension.core.bg.bookmarks.update(pageData.bookmarkId, { url: downloadData.filename }); } - await singlefile.extension.core.bg.bookmarks.update(pageData.bookmarkId, { url: downloadData.filename }); } } From 62ba410fb6f1c7f37c40fed476d969cca75f2b02 Mon Sep 17 00:00:00 2001 From: Gildas Date: Tue, 23 Jun 2020 23:23:28 +0200 Subject: [PATCH 12/22] bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 6ff3c146c..62f0863f6 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "64": "extension/ui/resources/icon_64.png", "128": "extension/ui/resources/icon_128.png" }, - "version": "1.17.49", + "version": "1.17.50", "description": "__MSG_extensionDescription__", "content_scripts": [ { From 3e15a0d08fbe050e90f3e21efa194c21234cd658 Mon Sep 17 00:00:00 2001 From: Gildas Date: Tue, 30 Jun 2020 16:45:58 +0200 Subject: [PATCH 13/22] added known issue in Firefox (see #405) --- README.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/README.MD b/README.MD index abe865e31..08e391da6 100644 --- a/README.MD +++ b/README.MD @@ -87,6 +87,7 @@ See https://addons.mozilla.org/firefox/addon/single-file/versions/ - Sometimes, SingleFile is unable to save the contents of sandboxed iframes because of [this bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1411641). - Waterfox - When opening pages saved with the option "Images > group duplicate images together" enabled, some duplicate images might not displayed. It is recommended to disable this option. + - When processing a page from the filesystem, external resources (e.g. images, stylesheets, fonts etc.) will not be embedded into the saved page. You can find more info about this bug [here](https://bugzilla.mozilla.org/show_bug.cgi?id=1644488). This bug has been closed by Mozilla as "WontFix". ## Troubleshooting unknown issues Please follow these steps if you find an unknown issue: From 236c5e9bc3ff09b22b09aee96940d76d157644ed Mon Sep 17 00:00:00 2001 From: Gildas Date: Tue, 30 Jun 2020 16:46:51 +0200 Subject: [PATCH 14/22] moved issue at the right place --- README.MD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.MD b/README.MD index 08e391da6..b07cbeaf8 100644 --- a/README.MD +++ b/README.MD @@ -85,9 +85,9 @@ See https://addons.mozilla.org/firefox/addon/single-file/versions/ - Firefox: - The "File name > file name conflict resolution" option does not work if set to "prompt for a name" - Sometimes, SingleFile is unable to save the contents of sandboxed iframes because of [this bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1411641). -- Waterfox - - When opening pages saved with the option "Images > group duplicate images together" enabled, some duplicate images might not displayed. It is recommended to disable this option. - When processing a page from the filesystem, external resources (e.g. images, stylesheets, fonts etc.) will not be embedded into the saved page. You can find more info about this bug [here](https://bugzilla.mozilla.org/show_bug.cgi?id=1644488). This bug has been closed by Mozilla as "WontFix". +- Waterfox + - When opening pages saved with the option "Images > group duplicate images together" enabled, some duplicate images might not displayed. It is recommended to disable this option. ## Troubleshooting unknown issues Please follow these steps if you find an unknown issue: From c398eaddcf9cdc77607f3990802c62589e28bf6c Mon Sep 17 00:00:00 2001 From: Gildas Date: Tue, 7 Jul 2020 20:06:32 +0200 Subject: [PATCH 15/22] added "zoom out the page" option (cf #440) --- _locales/de/messages.json | 4 + _locales/en/messages.json | 4 + _locales/es/messages.json | 4 + _locales/fr/messages.json | 4 + _locales/ja/messages.json | 4 + _locales/pl/messages.json | 4 + _locales/ru/messages.json | 4 + _locales/uk/messages.json | 4 + _locales/zh_CN/messages.json | 4 + _locales/zh_TW/messages.json | 4 + extension/core/bg/business.js | 2 +- extension/core/bg/config.js | 1 + extension/core/content/content-main.js | 6 + extension/ui/bg/ui-options.js | 6 + extension/ui/pages/help.html | 7 + extension/ui/pages/options.html | 4 + .../hooks/content/content-hooks-frames-web.js | 152 +++++++++++------- .../hooks/content/content-hooks-frames.js | 18 ++- .../lazy/content/content-lazy-loader.js | 6 + lib/single-file/single-file-core.js | 12 ++ 20 files changed, 194 insertions(+), 60 deletions(-) diff --git a/_locales/de/messages.json b/_locales/de/messages.json index 5b95833ba..270d856bd 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -235,6 +235,10 @@ "message": "maximale Inaktivitätszeit (ms)", "description": "Options page label: 'maximum idle time (ms)'" }, + "optionLoadDeferredImagesKeepZoomLevel": { + "message": "Seite verkleinern", + "description": "Options page label: 'zoom out the page'" + }, "optionRemoveAlternativeImages": { "message": "Bilder für alternative Bildschirmauflösungen entfernen", "description": "Options page label: 'remove images for alternative screen resolutions'" diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 884149ce4..edf7520df 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -235,6 +235,10 @@ "message": "maximum idle time (ms)", "description": "Options page label: 'maximum idle time (ms)'" }, + "optionLoadDeferredImagesKeepZoomLevel": { + "message": "zoom out the page", + "description": "Options page label: 'zoom out the page'" + }, "optionRemoveAlternativeImages": { "message": "remove images for alternative screen resolutions", "description": "Options page label: 'remove images for alternative screen resolutions'" diff --git a/_locales/es/messages.json b/_locales/es/messages.json index 6ee074d1c..c39e2f90c 100644 --- a/_locales/es/messages.json +++ b/_locales/es/messages.json @@ -235,6 +235,10 @@ "message": "periodo máximo de espera (ms)", "description": "Options page label: 'maximum idle time (ms)'" }, + "optionLoadDeferredImagesKeepZoomLevel": { + "message": "alejar la página", + "description": "Options page label: 'zoom out the page'" + }, "optionRemoveAlternativeImages": { "message": "eliminar imágenes para resoluciones alternativas de pantalla", "description": "Options page label: 'remove images for alternative screen resolutions'" diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json index 007890e47..5190860dc 100644 --- a/_locales/fr/messages.json +++ b/_locales/fr/messages.json @@ -235,6 +235,10 @@ "message": "temps d'inactivité maximal (ms)", "description": "Options page label: 'maximum idle time (ms)'" }, + "optionLoadDeferredImagesKeepZoomLevel": { + "message": "dézoomer la page", + "description": "Options page label: 'zoom out the page'" + }, "optionRemoveAlternativeImages": { "message": "supprimer les images pour des résolutions d'écran alternatives", "description": "Options page label: 'remove images for alternative screen resolutions'" diff --git a/_locales/ja/messages.json b/_locales/ja/messages.json index 14e5ff591..591b1e223 100644 --- a/_locales/ja/messages.json +++ b/_locales/ja/messages.json @@ -235,6 +235,10 @@ "message": "最大アイドル時間(ミリ秒)", "description": "Options page label: 'maximum idle time (ms)'" }, + "optionLoadDeferredImagesKeepZoomLevel": { + "message": "zoom out the page", + "description": "Options page label: 'zoom out the page'" + }, "optionRemoveAlternativeImages": { "message": "代替画面解像度用の画像を削除します", "description": "Options page label: 'remove images for alternative screen resolutions'" diff --git a/_locales/pl/messages.json b/_locales/pl/messages.json index cd212cf68..3a34b3d18 100644 --- a/_locales/pl/messages.json +++ b/_locales/pl/messages.json @@ -235,6 +235,10 @@ "message": "maksymalny czas bezczynności (ms)", "description": "Options page label: 'maximum idle time (ms)'" }, + "optionLoadDeferredImagesKeepZoomLevel": { + "message": "zoom out the page", + "description": "Options page label: 'zoom out the page'" + }, "optionRemoveAlternativeImages": { "message": "usuwaj obrazy dla alternatywnych rozdzielczości ekranu", "description": "Options page label: 'remove images for alternative screen resolutions'" diff --git a/_locales/ru/messages.json b/_locales/ru/messages.json index 2ca3aa6d7..f350e617c 100644 --- a/_locales/ru/messages.json +++ b/_locales/ru/messages.json @@ -235,6 +235,10 @@ "message": "максимальное время простоя (мс)", "description": "Options page label: 'maximum idle time (ms)'" }, + "optionLoadDeferredImagesKeepZoomLevel": { + "message": "zoom out the page", + "description": "Options page label: 'zoom out the page'" + }, "optionRemoveAlternativeImages": { "message": "удалить изображения для альтернативных разрешений экрана", "description": "Options page label: 'remove images for alternative screen resolutions'" diff --git a/_locales/uk/messages.json b/_locales/uk/messages.json index 69125874b..35f3ee790 100644 --- a/_locales/uk/messages.json +++ b/_locales/uk/messages.json @@ -235,6 +235,10 @@ "message": "максимальний час простою (мс)", "description": "Options page label: 'maximum idle time (ms)'" }, + "optionLoadDeferredImagesKeepZoomLevel": { + "message": "zoom out the page", + "description": "Options page label: 'zoom out the page'" + }, "optionRemoveAlternativeImages": { "message": "видалити зображення для альтернативних розширень екрану ", "description": "Options page label: 'remove images for alternative screen resolutions'" diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index 1309c61f8..503de3bb1 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -235,6 +235,10 @@ "message": "最长空闲时间(毫秒)", "description": "Options page label: 'maximum idle time (ms)'" }, + "optionLoadDeferredImagesKeepZoomLevel": { + "message": "zoom out the page", + "description": "Options page label: 'zoom out the page'" + }, "optionRemoveAlternativeImages": { "message": "移除用于备选分辨率的图片", "description": "Options page label: 'remove images for alternative screen resolutions'" diff --git a/_locales/zh_TW/messages.json b/_locales/zh_TW/messages.json index 17c421804..0a28a411e 100644 --- a/_locales/zh_TW/messages.json +++ b/_locales/zh_TW/messages.json @@ -235,6 +235,10 @@ "message": "最長空閒時間(毫秒)", "description": "Options page label: 'maximum idle time (ms)'" }, + "optionLoadDeferredImagesKeepZoomLevel": { + "message": "zoom out the page", + "description": "Options page label: 'zoom out the page'" + }, "optionRemoveAlternativeImages": { "message": "移除用於備選分辨率的圖片", "description": "Options page label: 'remove images for alternative screen resolutions'" diff --git a/extension/core/bg/business.js b/extension/core/bg/business.js index cb89a94cb..ec763dfb7 100644 --- a/extension/core/bg/business.js +++ b/extension/core/bg/business.js @@ -207,7 +207,7 @@ singlefile.extension.core.bg.business = (() => { const tabId = taskInfo.tab.id; const taskId = taskInfo.id; taskInfo.cancelled = true; - singlefile.extension.core.bg.tabs.sendMessage(tabId, { method: "content.cancelSave" }); + singlefile.extension.core.bg.tabs.sendMessage(tabId, { method: "content.cancelSave", resetZoomLevel: taskInfo.options.loadDeferredImagesKeepZoomLevel }); if (taskInfo.cancel) { taskInfo.cancel(); } diff --git a/extension/core/bg/config.js b/extension/core/bg/config.js index c66f376aa..26a59e0b6 100644 --- a/extension/core/bg/config.js +++ b/extension/core/bg/config.js @@ -43,6 +43,7 @@ singlefile.extension.core.bg.config = (() => { loadDeferredImagesMaxIdleTime: 1500, loadDeferredImagesBlockCookies: false, loadDeferredImagesBlockStorage: false, + loadDeferredImagesKeepZoomLevel: false, filenameTemplate: "{page-title} ({date-iso} {time-locale}).html", infobarTemplate: "", includeInfobar: false, diff --git a/extension/core/content/content-main.js b/extension/core/content/content-main.js index 70d6e2dd8..cf6632bbd 100644 --- a/extension/core/content/content-main.js +++ b/extension/core/content/content-main.js @@ -56,6 +56,9 @@ this.singlefile.extension.core.content.main = this.singlefile.extension.core.con ui.onEndPage(); browser.runtime.sendMessage({ method: "ui.processCancelled" }); } + if (message.resetZoomLevel) { + singlefile.lib.processors.lazy.content.loader.resetZoomLevel(); + } return {}; } if (message.method == "content.getSelectedLinks") { @@ -141,6 +144,9 @@ this.singlefile.extension.core.content.main = this.singlefile.extension.core.con if (!processor.cancelled) { if (event.type == event.RESOURCES_INITIALIZED) { maxIndex = event.detail.max; + if (options.loadDeferredImagesKeepZoomLevel) { + singlefile.lib.processors.lazy.content.loader.resetZoomLevel(); + } } if (event.type == event.RESOURCES_INITIALIZED || event.type == event.RESOURCE_LOADED) { if (event.type == event.RESOURCE_LOADED) { diff --git a/extension/ui/bg/ui-options.js b/extension/ui/bg/ui-options.js index 1c6f0e073..5ec2c11bd 100644 --- a/extension/ui/bg/ui-options.js +++ b/extension/ui/bg/ui-options.js @@ -42,6 +42,7 @@ const compressCSSLabel = document.getElementById("compressCSSLabel"); const loadDeferredImagesLabel = document.getElementById("loadDeferredImagesLabel"); const loadDeferredImagesMaxIdleTimeLabel = document.getElementById("loadDeferredImagesMaxIdleTimeLabel"); + const loadDeferredImagesKeepZoomLevelLabel = document.getElementById("loadDeferredImagesKeepZoomLevelLabel"); const addMenuEntryLabel = document.getElementById("addMenuEntryLabel"); const filenameTemplateLabel = document.getElementById("filenameTemplateLabel"); const filenameMaxLengthLabel = document.getElementById("filenameMaxLengthLabel"); @@ -118,6 +119,7 @@ const compressCSSInput = document.getElementById("compressCSSInput"); const loadDeferredImagesInput = document.getElementById("loadDeferredImagesInput"); const loadDeferredImagesMaxIdleTimeInput = document.getElementById("loadDeferredImagesMaxIdleTimeInput"); + const loadDeferredImagesKeepZoomLevelInput = document.getElementById("loadDeferredImagesKeepZoomLevelInput"); const contextMenuEnabledInput = document.getElementById("contextMenuEnabledInput"); const filenameTemplateInput = document.getElementById("filenameTemplateInput"); const filenameMaxLengthInput = document.getElementById("filenameMaxLengthInput"); @@ -437,6 +439,7 @@ compressCSSLabel.textContent = browser.i18n.getMessage("optionCompressCSS"); loadDeferredImagesLabel.textContent = browser.i18n.getMessage("optionLoadDeferredImages"); loadDeferredImagesMaxIdleTimeLabel.textContent = browser.i18n.getMessage("optionLoadDeferredImagesMaxIdleTime"); + loadDeferredImagesKeepZoomLevelLabel.textContent = browser.i18n.getMessage("optionLoadDeferredImagesKeepZoomLevel"); addMenuEntryLabel.textContent = browser.i18n.getMessage("optionAddMenuEntry"); filenameTemplateLabel.textContent = browser.i18n.getMessage("optionFilenameTemplate"); filenameMaxLengthLabel.textContent = browser.i18n.getMessage("optionFilenameMaxLength"); @@ -620,6 +623,8 @@ loadDeferredImagesInput.checked = profileOptions.loadDeferredImages && !profileOptions.saveRawPage; loadDeferredImagesInput.disabled = profileOptions.saveRawPage; loadDeferredImagesMaxIdleTimeInput.value = profileOptions.loadDeferredImagesMaxIdleTime; + loadDeferredImagesKeepZoomLevelInput.checked = profileOptions.loadDeferredImagesKeepZoomLevel && !profileOptions.saveRawPage; + loadDeferredImagesKeepZoomLevelInput.disabled = !profileOptions.loadDeferredImages || profileOptions.saveRawPape; loadDeferredImagesMaxIdleTimeInput.disabled = !profileOptions.loadDeferredImages || profileOptions.saveRawPage; contextMenuEnabledInput.checked = profileOptions.contextMenuEnabled; filenameTemplateInput.value = profileOptions.filenameTemplate; @@ -696,6 +701,7 @@ compressCSS: compressCSSInput.checked, loadDeferredImages: loadDeferredImagesInput.checked, loadDeferredImagesMaxIdleTime: Math.max(loadDeferredImagesMaxIdleTimeInput.value, 0), + loadDeferredImagesKeepZoomLevel: loadDeferredImagesKeepZoomLevelInput.checked, contextMenuEnabled: contextMenuEnabledInput.checked, filenameTemplate: filenameTemplateInput.value, filenameMaxLength: filenameMaxLengthInput.value, diff --git a/extension/ui/pages/help.html b/extension/ui/pages/help.html index e89ca09fc..85bbb723f 100644 --- a/extension/ui/pages/help.html +++ b/extension/ui/pages/help.html @@ -267,6 +267,13 @@

Save a complete page into a single HTML file

for example the network or system conditions are degraded. You can also decrease this value otherwise.

+
  • Option: zoom out + the page +

    Check this option to save the entire content of a page by zooming out the page. This can help + saving pages using infinite virtual lists for example. +

    +

    It is recommended to uncheck this option

    +
  • Option: remove images for alternative screen resolutions

    Check this option to remove images that are alternatives in lower and/or higher resolutions diff --git a/extension/ui/pages/options.html b/extension/ui/pages/options.html index 557738b7b..f8ab892f8 100644 --- a/extension/ui/pages/options.html +++ b/extension/ui/pages/options.html @@ -135,6 +135,10 @@

    +
    + + +
    diff --git a/lib/single-file/processors/hooks/content/content-hooks-frames-web.js b/lib/single-file/processors/hooks/content/content-hooks-frames-web.js index f35e23fe9..07b69888d 100644 --- a/lib/single-file/processors/hooks/content/content-hooks-frames-web.js +++ b/lib/single-file/processors/hooks/content/content-hooks-frames-web.js @@ -27,6 +27,9 @@ const LOAD_DEFERRED_IMAGES_START_EVENT = "single-file-load-deferred-images-start"; const LOAD_DEFERRED_IMAGES_END_EVENT = "single-file-load-deferred-images-end"; + const LOAD_DEFERRED_IMAGES_KEEP_ZOOM_LEVEL_START_EVENT = "single-file-load-deferred-images-keep-zoom-level-start"; + const LOAD_DEFERRED_IMAGES_KEEP_ZOOM_LEVEL_END_EVENT = "single-file-load-deferred-images-keep-zoom-level-end"; + const LOAD_DEFERRED_IMAGES_RESET_ZOOM_LEVEL_END_EVENT = "single-file-load-deferred-images-keep-zoom-level-reset"; const BLOCK_COOKIES_START_EVENT = "single-file-block-cookies-start"; const BLOCK_COOKIES_END_EVENT = "single-file-block-cookies-end"; const BLOCK_STORAGE_START_EVENT = "single-file-block-storage-start"; @@ -60,36 +63,41 @@ const observers = new Map(); const observedElements = new Map(); - addEventListener.call(window, LOAD_DEFERRED_IMAGES_START_EVENT, () => { + addEventListener.call(window, LOAD_DEFERRED_IMAGES_START_EVENT, () => loadDeferredImagesStart()); + addEventListener.call(window, LOAD_DEFERRED_IMAGES_KEEP_ZOOM_LEVEL_START_EVENT, () => loadDeferredImagesStart(true)); + + function loadDeferredImagesStart(keepZoomLevel) { const scrollingElement = document.scrollingElement || document.documentElement; const clientHeight = scrollingElement.clientHeight; const clientWidth = scrollingElement.clientWidth; const scrollHeight = Math.max(scrollingElement.scrollHeight - clientHeight, clientHeight); const scrollWidth = Math.max(scrollingElement.scrollWidth - clientWidth, clientWidth); - scrollingElement.__defineGetter__("clientHeight", () => scrollHeight); - scrollingElement.__defineGetter__("clientWidth", () => scrollWidth); - screen.__defineGetter__("height", () => scrollHeight); - screen.__defineGetter__("width", () => scrollWidth); document.querySelectorAll("[loading=lazy]").forEach(element => { element.loading = "eager"; element.setAttribute(LAZY_LOAD_ATTRIBUTE, ""); }); - if (!window._singleFile_getBoundingClientRect) { - window._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect; - Element.prototype.getBoundingClientRect = function () { - const boundingRect = window._singleFile_getBoundingClientRect.call(this); - if (this == scrollingElement) { - boundingRect.__defineGetter__("height", () => scrollHeight); - boundingRect.__defineGetter__("bottom", () => scrollHeight + boundingRect.top); - boundingRect.__defineGetter__("width", () => scrollWidth); - boundingRect.__defineGetter__("right", () => scrollWidth + boundingRect.left); - } - return boundingRect; - }; - window._singleFile_innerHeight = window.innerHeight; - window._singleFile_innerWidth = window.innerWidth; - window.__defineGetter__("innerHeight", () => scrollHeight); - window.__defineGetter__("innerWidth", () => scrollWidth); + if (!keepZoomLevel) { + scrollingElement.__defineGetter__("clientHeight", () => scrollHeight); + scrollingElement.__defineGetter__("clientWidth", () => scrollWidth); + screen.__defineGetter__("height", () => scrollHeight); + screen.__defineGetter__("width", () => scrollWidth); + if (!window._singleFile_getBoundingClientRect) { + window._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect; + Element.prototype.getBoundingClientRect = function () { + const boundingRect = window._singleFile_getBoundingClientRect.call(this); + if (this == scrollingElement) { + boundingRect.__defineGetter__("height", () => scrollHeight); + boundingRect.__defineGetter__("bottom", () => scrollHeight + boundingRect.top); + boundingRect.__defineGetter__("width", () => scrollWidth); + boundingRect.__defineGetter__("right", () => scrollWidth + boundingRect.left); + } + return boundingRect; + }; + window._singleFile_innerHeight = window.innerHeight; + window._singleFile_innerWidth = window.innerWidth; + window.__defineGetter__("innerHeight", () => scrollHeight); + window.__defineGetter__("innerWidth", () => scrollWidth); + } } if (!window._singleFileImage) { const Image = window.Image; @@ -123,8 +131,14 @@ }; }); } - const zoomFactorX = (clientHeight + window.scrollY) / scrollHeight; - const zoomFactorY = (clientWidth + window.scrollX) / scrollWidth; + let zoomFactorX, zoomFactorY; + if (keepZoomLevel) { + zoomFactorX = clientHeight / scrollHeight; + zoomFactorY = clientWidth / scrollWidth; + } else { + zoomFactorX = (clientHeight + window.scrollY) / scrollHeight; + zoomFactorY = (clientWidth + window.scrollX) / scrollWidth; + } const zoomFactor = Math.min(zoomFactorX, zoomFactorY); if (zoomFactor < 1) { const transform = document.documentElement.style.getPropertyValue("transform"); @@ -135,54 +149,78 @@ document.documentElement.style.setProperty("transform", "scale3d(" + zoomFactor + ", " + zoomFactor + ", 1)", "important"); dispatchEvent.call(window, new UIEvent("resize")); dispatchEvent.call(window, new UIEvent("scroll")); - document.documentElement.style.setProperty("transform", transform, transformPriority); - document.documentElement.style.setProperty("transform-origin", transformOrigin, transformOriginPriority); - } - dispatchEvent.call(window, new UIEvent("resize")); - dispatchEvent.call(window, new UIEvent("scroll")); - const docBoundingRect = scrollingElement.getBoundingClientRect(); - [...observers].forEach(([intersectionObserver, observer]) => { - const rootBoundingRect = observer.options && observer.options.root && observer.options.root.getBoundingClientRect(); - const targetElements = observedElements.get(intersectionObserver); - if (targetElements) { - observer.callback(targetElements.map(target => { - const boundingClientRect = target.getBoundingClientRect(); - const isIntersecting = true; - const intersectionRatio = 1; - const rootBounds = observer.options && observer.options.root ? rootBoundingRect : docBoundingRect; - const time = 0; - return { target, intersectionRatio, boundingClientRect, intersectionRect: boundingClientRect, isIntersecting, rootBounds, time }; - }), intersectionObserver); + if (keepZoomLevel) { + document.documentElement.style.setProperty("-sf-transform", transform, transformPriority); + document.documentElement.style.setProperty("-sf-transform-origin", transformOrigin, transformOriginPriority); + } else { + document.documentElement.style.setProperty("transform", transform, transformPriority); + document.documentElement.style.setProperty("transform-origin", transformOrigin, transformOriginPriority); } - }); + } + if (!keepZoomLevel) { + dispatchEvent.call(window, new UIEvent("resize")); + dispatchEvent.call(window, new UIEvent("scroll")); + const docBoundingRect = scrollingElement.getBoundingClientRect(); + [...observers].forEach(([intersectionObserver, observer]) => { + const rootBoundingRect = observer.options && observer.options.root && observer.options.root.getBoundingClientRect(); + const targetElements = observedElements.get(intersectionObserver); + if (targetElements) { + observer.callback(targetElements.map(target => { + const boundingClientRect = target.getBoundingClientRect(); + const isIntersecting = true; + const intersectionRatio = 1; + const rootBounds = observer.options && observer.options.root ? rootBoundingRect : docBoundingRect; + const time = 0; + return { target, intersectionRatio, boundingClientRect, intersectionRect: boundingClientRect, isIntersecting, rootBounds, time }; + }), intersectionObserver); + } + }); + } + } + + addEventListener.call(window, LOAD_DEFERRED_IMAGES_END_EVENT, () => loadDeferredImagesEnd()); + addEventListener.call(window, LOAD_DEFERRED_IMAGES_KEEP_ZOOM_LEVEL_END_EVENT, () => loadDeferredImagesEnd(true)); + addEventListener.call(window, LOAD_DEFERRED_IMAGES_RESET_ZOOM_LEVEL_END_EVENT, () => { + const transform = document.documentElement.style.getPropertyValue("-sf-transform"); + const transformPriority = document.documentElement.style.getPropertyPriority("-sf-transform"); + const transformOrigin = document.documentElement.style.getPropertyValue("-sf-transform-origin"); + const transformOriginPriority = document.documentElement.style.getPropertyPriority("-sf-transform-origin"); + document.documentElement.style.setProperty("transform", transform, transformPriority); + document.documentElement.style.setProperty("transform-origin", transformOrigin, transformOriginPriority); + document.documentElement.style.removeProperty("-sf-transform"); + document.documentElement.style.removeProperty("-sf-transform-origin"); }); - addEventListener.call(window, LOAD_DEFERRED_IMAGES_END_EVENT, () => { + function loadDeferredImagesEnd(keepZoomLevel) { const scrollingElement = document.scrollingElement || document.documentElement; document.querySelectorAll("[" + LAZY_LOAD_ATTRIBUTE + "]").forEach(element => { element.loading = "lazy"; element.removeAttribute(LAZY_LOAD_ATTRIBUTE); }); - delete scrollingElement.clientHeight; - delete scrollingElement.clientWidth; - delete screen.height; - delete screen.width; - if (window._singleFile_getBoundingClientRect) { - Element.prototype.getBoundingClientRect = window._singleFile_getBoundingClientRect; - window.innerHeight = window._singleFile_innerHeight; - window.innerWidth = window._singleFile_innerWidth; - delete window._singleFile_getBoundingClientRect; - delete window._singleFile_innerHeight; - delete window._singleFile_innerWidth; + if (!keepZoomLevel) { + delete scrollingElement.clientHeight; + delete scrollingElement.clientWidth; + delete screen.height; + delete screen.width; + if (window._singleFile_getBoundingClientRect) { + Element.prototype.getBoundingClientRect = window._singleFile_getBoundingClientRect; + window.innerHeight = window._singleFile_innerHeight; + window.innerWidth = window._singleFile_innerWidth; + delete window._singleFile_getBoundingClientRect; + delete window._singleFile_innerHeight; + delete window._singleFile_innerWidth; + } } if (window._singleFileImage) { delete window.Image; window.Image = window._singleFileImage; delete window._singleFileImage; } - dispatchEvent.call(window, new UIEvent("resize")); - dispatchEvent.call(window, new UIEvent("scroll")); - }); + if (!keepZoomLevel) { + dispatchEvent.call(window, new UIEvent("resize")); + dispatchEvent.call(window, new UIEvent("scroll")); + } + } addEventListener.call(window, BLOCK_COOKIES_START_EVENT, () => { try { diff --git a/lib/single-file/processors/hooks/content/content-hooks-frames.js b/lib/single-file/processors/hooks/content/content-hooks-frames.js index 5d8a17b04..3b76963bc 100644 --- a/lib/single-file/processors/hooks/content/content-hooks-frames.js +++ b/lib/single-file/processors/hooks/content/content-hooks-frames.js @@ -27,6 +27,9 @@ this.singlefile.lib.processors.hooks.content.frames = this.singlefile.lib.proces const LOAD_DEFERRED_IMAGES_START_EVENT = "single-file-load-deferred-images-start"; const LOAD_DEFERRED_IMAGES_END_EVENT = "single-file-load-deferred-images-end"; + const LOAD_DEFERRED_IMAGES_KEEP_ZOOM_LEVEL_START_EVENT = "single-file-load-deferred-images-keep-zoom-level-start"; + const LOAD_DEFERRED_IMAGES_KEEP_ZOOM_LEVEL_END_EVENT = "single-file-load-deferred-images-keep-zoom-level-end"; + const LOAD_DEFERRED_IMAGES_RESET_ZOOM_LEVEL_END_EVENT = "single-file-load-deferred-images-keep-zoom-level-reset"; const BLOCK_COOKIES_START_EVENT = "single-file-block-cookies-start"; const BLOCK_COOKIES_END_EVENT = "single-file-block-cookies-end"; const BLOCK_STORAGE_START_EVENT = "single-file-block-storage-start"; @@ -80,7 +83,11 @@ this.singlefile.lib.processors.hooks.content.frames = this.singlefile.lib.proces if (options.loadDeferredImagesBlockStorage) { dispatchEvent.call(window, new CustomEvent(BLOCK_STORAGE_START_EVENT)); } - dispatchEvent.call(window, new CustomEvent(LOAD_DEFERRED_IMAGES_START_EVENT)); + if (options.loadDeferredImagesKeepZoomLevel) { + dispatchEvent.call(window, new CustomEvent(LOAD_DEFERRED_IMAGES_KEEP_ZOOM_LEVEL_START_EVENT)); + } else { + dispatchEvent.call(window, new CustomEvent(LOAD_DEFERRED_IMAGES_START_EVENT)); + } }, loadDeferredImagesEnd: options => { if (options.loadDeferredImagesBlockCookies) { @@ -89,7 +96,14 @@ this.singlefile.lib.processors.hooks.content.frames = this.singlefile.lib.proces if (options.loadDeferredImagesBlockStorage) { dispatchEvent.call(window, new CustomEvent(BLOCK_STORAGE_END_EVENT)); } - dispatchEvent.call(window, new CustomEvent(LOAD_DEFERRED_IMAGES_END_EVENT)); + if (options.loadDeferredImagesKeepZoomLevel) { + dispatchEvent.call(window, new CustomEvent(LOAD_DEFERRED_IMAGES_KEEP_ZOOM_LEVEL_END_EVENT)); + } else { + dispatchEvent.call(window, new CustomEvent(LOAD_DEFERRED_IMAGES_END_EVENT)); + } + }, + loadDeferredImagesResetZoomLevel: () => { + dispatchEvent.call(window, new CustomEvent(LOAD_DEFERRED_IMAGES_RESET_ZOOM_LEVEL_END_EVENT)); }, LOAD_IMAGE_EVENT, IMAGE_LOADED_EVENT diff --git a/lib/single-file/processors/lazy/content/content-lazy-loader.js b/lib/single-file/processors/lazy/content/content-lazy-loader.js index ff204e972..92ca77fc0 100644 --- a/lib/single-file/processors/lazy/content/content-lazy-loader.js +++ b/lib/single-file/processors/lazy/content/content-lazy-loader.js @@ -44,6 +44,12 @@ this.singlefile.lib.processors.lazy.content.loader = this.singlefile.lib.process if (scrollY <= maxScrollY && scrollX <= maxScrollX) { return process(options); } + }, + resetZoomLevel: () => { + const frames = singlefile.lib.processors.hooks.content.frames; + if (frames) { + frames.loadDeferredImagesResetZoomLevel(); + } } }; diff --git a/lib/single-file/single-file-core.js b/lib/single-file/single-file-core.js index 7ca4bb1bb..65afd546c 100644 --- a/lib/single-file/single-file-core.js +++ b/lib/single-file/single-file-core.js @@ -93,6 +93,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => { const STAGES = [{ sequential: [ { action: "preProcessPage" }, + { option: "loadDeferredImagesKeepZoomLevel", action: "resetZoomLevel" }, { action: "replaceStyleContents" }, { action: "resetCharsetMeta" }, { option: "saveFavicon", action: "saveFavicon" }, @@ -1351,6 +1352,17 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => { } } + resetZoomLevel() { + const transform = this.doc.documentElement.style.getPropertyValue("-sf-transform"); + const transformPriority = this.doc.documentElement.style.getPropertyPriority("-sf-transform"); + const transformOrigin = this.doc.documentElement.style.getPropertyValue("-sf-transform-origin"); + const transformOriginPriority = this.doc.documentElement.style.getPropertyPriority("-sf-transform-origin"); + this.doc.documentElement.style.setProperty("transform", transform, transformPriority); + this.doc.documentElement.style.setProperty("transform-origin", transformOrigin, transformOriginPriority); + this.doc.documentElement.style.removeProperty("-sf-transform"); + this.doc.documentElement.style.removeProperty("-sf-transform-origin"); + } + async insertMAFFMetaData() { const maffMetaData = await this.maffMetaDataPromise; if (maffMetaData && maffMetaData.content) { From f8b4c6b36144614169f5c2d4615b9d7286f9a9b4 Mon Sep 17 00:00:00 2001 From: Gildas Date: Tue, 7 Jul 2020 20:09:29 +0200 Subject: [PATCH 16/22] bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 62f0863f6..b1fbda138 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "64": "extension/ui/resources/icon_64.png", "128": "extension/ui/resources/icon_128.png" }, - "version": "1.17.50", + "version": "1.17.51", "description": "__MSG_extensionDescription__", "content_scripts": [ { From eaec70c072791c2d716a51c1ab3ffbcf01a6b38f Mon Sep 17 00:00:00 2001 From: xesarni <25767588+xesarni@users.noreply.github.com> Date: Tue, 7 Jul 2020 23:32:25 +0200 Subject: [PATCH 17/22] Updated Polish translation --- _locales/pl/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_locales/pl/messages.json b/_locales/pl/messages.json index 3a34b3d18..2a36ebcb7 100644 --- a/_locales/pl/messages.json +++ b/_locales/pl/messages.json @@ -236,7 +236,7 @@ "description": "Options page label: 'maximum idle time (ms)'" }, "optionLoadDeferredImagesKeepZoomLevel": { - "message": "zoom out the page", + "message": "pomniejsz stronę", "description": "Options page label: 'zoom out the page'" }, "optionRemoveAlternativeImages": { From 68d59e7ac7616098c3e19f3946f94e464f46c014 Mon Sep 17 00:00:00 2001 From: frostblazergit <48089979+frostblazergit@users.noreply.github.com> Date: Wed, 8 Jul 2020 14:52:47 +0800 Subject: [PATCH 18/22] updated Chinese translation --- _locales/zh_CN/messages.json | 2 +- _locales/zh_TW/messages.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index 503de3bb1..6e14b5457 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -236,7 +236,7 @@ "description": "Options page label: 'maximum idle time (ms)'" }, "optionLoadDeferredImagesKeepZoomLevel": { - "message": "zoom out the page", + "message": "缩小页面", "description": "Options page label: 'zoom out the page'" }, "optionRemoveAlternativeImages": { diff --git a/_locales/zh_TW/messages.json b/_locales/zh_TW/messages.json index 0a28a411e..2cfdd71ea 100644 --- a/_locales/zh_TW/messages.json +++ b/_locales/zh_TW/messages.json @@ -236,7 +236,7 @@ "description": "Options page label: 'maximum idle time (ms)'" }, "optionLoadDeferredImagesKeepZoomLevel": { - "message": "zoom out the page", + "message": "縮小頁面", "description": "Options page label: 'zoom out the page'" }, "optionRemoveAlternativeImages": { From 939c324ff098b635c03d2bbddfa48e6ded2312e2 Mon Sep 17 00:00:00 2001 From: Gildas Date: Wed, 8 Jul 2020 18:54:46 +0200 Subject: [PATCH 19/22] ignore font src ending with "\9" (IE hack) --- lib/single-file/modules/css-fonts-alt-minifier.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/single-file/modules/css-fonts-alt-minifier.js b/lib/single-file/modules/css-fonts-alt-minifier.js index 2ae38d42b..4f7b56714 100644 --- a/lib/single-file/modules/css-fonts-alt-minifier.js +++ b/lib/single-file/modules/css-fonts-alt-minifier.js @@ -273,11 +273,11 @@ this.singlefile.lib.modules.fontsAltMinifier = this.singlefile.lib.modules.fonts const cssTree = singlefile.lib.vendor.cssTree; let property; if (ruleData.block.children) { - property = ruleData.block.children.filter(node => node.property == propertyName).tail; + property = ruleData.block.children.filter(node => node.property == propertyName && !cssTree.generate(node.value).match(/\\9$/)).tail; } if (property) { try { - return cssTree.generate(property.data.value).replace(/\\9$/, ""); + return cssTree.generate(property.data.value); } catch (error) { // ignored } From 5491351bf661dce58b37e8971f8c1d55fd385d13 Mon Sep 17 00:00:00 2001 From: Gildas Date: Wed, 8 Jul 2020 20:19:09 +0200 Subject: [PATCH 20/22] added try/catch --- lib/single-file/modules/css-fonts-alt-minifier.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/single-file/modules/css-fonts-alt-minifier.js b/lib/single-file/modules/css-fonts-alt-minifier.js index 4f7b56714..4fd0645bc 100644 --- a/lib/single-file/modules/css-fonts-alt-minifier.js +++ b/lib/single-file/modules/css-fonts-alt-minifier.js @@ -273,7 +273,13 @@ this.singlefile.lib.modules.fontsAltMinifier = this.singlefile.lib.modules.fonts const cssTree = singlefile.lib.vendor.cssTree; let property; if (ruleData.block.children) { - property = ruleData.block.children.filter(node => node.property == propertyName && !cssTree.generate(node.value).match(/\\9$/)).tail; + property = ruleData.block.children.filter(node => { + try { + return node.property == propertyName && !cssTree.generate(node.value).match(/\\9$/); + } catch (error) { + // ignored + } + }).tail; } if (property) { try { From 2b7d5eedaae3e0b170721e000a30cee252d0ffe8 Mon Sep 17 00:00:00 2001 From: Gildas Date: Wed, 8 Jul 2020 20:20:27 +0200 Subject: [PATCH 21/22] added fallback in the catch block --- lib/single-file/modules/css-fonts-alt-minifier.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/single-file/modules/css-fonts-alt-minifier.js b/lib/single-file/modules/css-fonts-alt-minifier.js index 4fd0645bc..4455b2ada 100644 --- a/lib/single-file/modules/css-fonts-alt-minifier.js +++ b/lib/single-file/modules/css-fonts-alt-minifier.js @@ -277,7 +277,7 @@ this.singlefile.lib.modules.fontsAltMinifier = this.singlefile.lib.modules.fonts try { return node.property == propertyName && !cssTree.generate(node.value).match(/\\9$/); } catch (error) { - // ignored + return node.property == propertyName; } }).tail; } From 30bd59088d7cd422ee577edf5ca7df020f9ad0b2 Mon Sep 17 00:00:00 2001 From: Gildas Date: Wed, 8 Jul 2020 20:25:36 +0200 Subject: [PATCH 22/22] bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index b1fbda138..85e2f442b 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "64": "extension/ui/resources/icon_64.png", "128": "extension/ui/resources/icon_128.png" }, - "version": "1.17.51", + "version": "1.17.52", "description": "__MSG_extensionDescription__", "content_scripts": [ {