Skip to content

Commit

Permalink
Merge pull request #7 from gildas-lormeau/master
Browse files Browse the repository at this point in the history
upd
  • Loading branch information
solokot authored Jul 9, 2020
2 parents aa6efa3 + 30bd590 commit 7073f1f
Show file tree
Hide file tree
Showing 26 changed files with 265 additions and 121 deletions.
3 changes: 2 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +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).
- 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.
- 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:
Expand Down
4 changes: 4 additions & 0 deletions _locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
20 changes: 12 additions & 8 deletions _locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
"description": "Options page label: 'template'"
},
"optionFilenameMaxLength": {
"message": "max length (bytes)",
"message": "最大長(バイト)",
"description": "Options page label: 'max length (bytes)'"
},
"optionConfirmFilename": {
Expand All @@ -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'"
},
Expand Down Expand Up @@ -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'"
Expand Down Expand Up @@ -376,7 +380,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": {
Expand Down Expand Up @@ -416,7 +420,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": {
Expand Down Expand Up @@ -631,4 +635,4 @@
"message": "Cancel",
"description": "Add URLs popup cancel button: 'Cancel'"
}
}
}
4 changes: 4 additions & 0 deletions _locales/pl/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@
"message": "maksymalny czas bezczynności (ms)",
"description": "Options page label: 'maximum idle time (ms)'"
},
"optionLoadDeferredImagesKeepZoomLevel": {
"message": "pomniejsz stronę",
"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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/uk/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
6 changes: 5 additions & 1 deletion _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -235,6 +235,10 @@
"message": "最长空闲时间(毫秒)",
"description": "Options page label: 'maximum idle time (ms)'"
},
"optionLoadDeferredImagesKeepZoomLevel": {
"message": "缩小页面",
"description": "Options page label: 'zoom out the page'"
},
"optionRemoveAlternativeImages": {
"message": "移除用于备选分辨率的图片",
"description": "Options page label: 'remove images for alternative screen resolutions'"
Expand Down
6 changes: 5 additions & 1 deletion _locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -235,6 +235,10 @@
"message": "最長空閒時間(毫秒)",
"description": "Options page label: 'maximum idle time (ms)'"
},
"optionLoadDeferredImagesKeepZoomLevel": {
"message": "縮小頁面",
"description": "Options page label: 'zoom out the page'"
},
"optionRemoveAlternativeImages": {
"message": "移除用於備選分辨率的圖片",
"description": "Options page label: 'remove images for alternative screen resolutions'"
Expand Down
2 changes: 1 addition & 1 deletion extension/core/bg/business.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions extension/core/bg/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
72 changes: 36 additions & 36 deletions extension/core/bg/downloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 });
}
}

Expand Down
6 changes: 6 additions & 0 deletions extension/core/content/content-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions extension/ui/bg/ui-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions extension/ui/content/content-ui-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -378,17 +378,18 @@ 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");
maskElement.style.setProperty("width", "100%", "important");
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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit 7073f1f

Please sign in to comment.