Kaynağa Gözat

add `Infobar > keep infobar open` option (fix #1516, see #1504)

Gildas 1 yıl önce
ebeveyn
işleme
6d00e15c08

+ 4 - 0
_locales/de/messages.json

@@ -175,6 +175,10 @@
 		"message": "Einfügen Inhalt des Infoknopfs in die gespeicherte Seite",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "Infobar offen halten",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "Enthalten nicht das gespeicherte Datum",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/en/messages.json

@@ -175,6 +175,10 @@
 		"message": "include the infobar in the saved page",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "keep infobar open",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "do not include the saved date",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/es/messages.json

@@ -175,6 +175,10 @@
 		"message": "incluir la barra informativa en la página guardada",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "mantener abierta la barra de información",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "no incluya la fecha guardada",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/fr/messages.json

@@ -175,6 +175,10 @@
 		"message": "inclure la barre d'information dans la page sauvegardée",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "maintenir la barre d'information ouverte",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "ne pas inclure la date de sauvegarde",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/it/messages.json

@@ -175,6 +175,10 @@
 		"message": "includi una barra informativa nella pagina salvata",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "mantenere aperto l'infobar",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "non includere la data di salvataggio",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/ja/messages.json

@@ -175,6 +175,10 @@
 		"message": "保存されたページに、infobar を含める",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "インフォバーを開いておく",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "保存日時を含めない",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/nl_NL/messages.json

@@ -175,6 +175,10 @@
 		"message": "neem de infobalk op in de opgeslagen pagina",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "infobalk openhouden",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "sla de opgeslagen datum niet op",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/pl/messages.json

@@ -175,6 +175,10 @@
 		"message": "dołączaj pasek informacyjny do zapisanej strony",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "keep infobar open",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "nie dołączaj zapisanej daty",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/pt_PT/messages.json

@@ -175,6 +175,10 @@
 		"message": "incluir a barra de informações na página guardada",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "manter o infobar aberto",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "não incluir a data em que foi guardada",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/pt_br/messages.json

@@ -175,6 +175,10 @@
 		"message": "incluir o infobar na página salva",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "manter o infobar aberto",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "não incluir data de salvamento",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/ru/messages.json

@@ -175,6 +175,10 @@
 		"message": "добавить информационную панель в сохраняемую страницу",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "keep infobar open",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "не включать дату сохранения",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/tr/messages.json

@@ -175,6 +175,10 @@
 		"message": "bilgi çubuğunu kaydedilen sayfaya dahil et",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "bilgi çubuğunu açık tut",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "kaydedilen tarihi dahil etme",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/uk/messages.json

@@ -175,6 +175,10 @@
 		"message": "додавати інформ. панель в сторінку що зберігається",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "тримати інфопанель відкритою",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "не включати збережену дату",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/zh_CN/messages.json

@@ -175,6 +175,10 @@
 		"message": "在已保存页面中将信息栏包括在内",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "保持信息栏打开",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "不包括保存日期",
 		"description": "Options page label: 'do not include the saved date'"

+ 4 - 0
_locales/zh_TW/messages.json

@@ -175,6 +175,10 @@
 		"message": "在已保存頁面中將信息欄包括在內",
 		"description": "Options page label: 'include the infobar in the saved page'"
 	},
+	"optionOpenInfobar": {
+		"message": "保持資訊列開啟",
+		"description": "Options page label: 'keep infobar open'"
+	},
 	"optionRemoveInfobarSavedDate": {
 		"message": "不包括保存日期",
 		"description": "Options page label: 'do not include the saved date'"

+ 1 - 0
src/core/bg/config.js

@@ -63,6 +63,7 @@ const DEFAULT_CONFIG = {
 	filenameTemplate: "%if-empty<{page-title}|No title> ({date-locale} {time-locale}).{filename-extension}",
 	infobarTemplate: "",
 	includeInfobar: !IS_NOT_SAFARI,
+	openInfobar: false,
 	confirmInfobarContent: false,
 	autoClose: false,
 	confirmFilename: false,

+ 4 - 2
src/core/bg/downloads.js

@@ -242,7 +242,8 @@ async function downloadContent(contents, tab, incognito, message) {
 					filenameReplacementCharacter: message.filenameReplacementCharacter,
 					bookmarkId: message.bookmarkId,
 					replaceBookmarkURL: message.replaceBookmarkURL,
-					includeInfobar: message.includeInfobar
+					includeInfobar: message.includeInfobar,
+					openInfobar: message.openInfobar
 				});
 				if (!response) {
 					throw new Error("upload_cancelled");
@@ -368,7 +369,8 @@ async function downloadCompressedContent(message, tab) {
 					filenameReplacementCharacter: message.filenameReplacementCharacter,
 					bookmarkId: message.bookmarkId,
 					replaceBookmarkURL: message.replaceBookmarkURL,
-					includeInfobar: message.includeInfobar
+					includeInfobar: message.includeInfobar,
+					openInfobar: message.openInfobar
 				});
 			}
 			if (message.bookmarkId && message.replaceBookmarkURL && response && response.url) {

+ 1 - 0
src/core/common/download.js

@@ -90,6 +90,7 @@ async function downloadPage(pageData, options) {
 		applySystemTheme: options.applySystemTheme,
 		defaultEditorMode: options.defaultEditorMode,
 		includeInfobar: options.includeInfobar,
+		openInfobar: options.openInfobar,
 		warnUnsavedPage: options.warnUnsavedPage,
 		createRootDirectory: options.createRootDirectory,
 		selfExtractingArchive: options.selfExtractingArchive,

+ 3 - 1
src/ui/bg/ui-editor.js

@@ -529,6 +529,7 @@ function savePage() {
 		method: "getContent",
 		compressHTML: tabData.options.compressHTML,
 		includeInfobar: tabData.options.includeInfobar,
+		openInfobar: tabData.options.openInfobar,
 		backgroundSave: tabData.options.backgroundSave,
 		updatedResources,
 		filename: tabData.filename,
@@ -545,7 +546,8 @@ function savePage() {
 
 function displayInfobar() {
 	editorElement.contentWindow.postMessage(JSON.stringify({
-		method: "displayInfobar"
+		method: "displayInfobar",
+		openInfobar: tabData.options.openInfobar
 	}), "*");
 }
 

+ 5 - 2
src/ui/bg/ui-options.js

@@ -21,8 +21,6 @@
  *   Source.
  */
 
-import { save } from "../../core/bg/companion.js";
-
 /* global browser, window, document, localStorage, FileReader, location, fetch, TextDecoder, DOMParser, HTMLElement, MouseEvent */
 
 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==";
@@ -195,6 +193,7 @@ const infobarTemplateLabel = document.getElementById("infobarTemplateLabel");
 const blockMixedContentLabel = document.getElementById("blockMixedContentLabel");
 const saveOriginalURLsLabel = document.getElementById("saveOriginalURLsLabel");
 const includeInfobarLabel = document.getElementById("includeInfobarLabel");
+const openInfobarLabel = document.getElementById("openInfobarLabel");
 const removeInfobarSavedDateLabel = document.getElementById("removeInfobarSavedDateLabel");
 const miscLabel = document.getElementById("miscLabel");
 const helpLabel = document.getElementById("helpLabel");
@@ -299,6 +298,7 @@ const infobarTemplateInput = document.getElementById("infobarTemplateInput");
 const blockMixedContentInput = document.getElementById("blockMixedContentInput");
 const saveOriginalURLsInput = document.getElementById("saveOriginalURLsInput");
 const includeInfobarInput = document.getElementById("includeInfobarInput");
+const openInfobarInput = document.getElementById("openInfobarInput");
 const removeInfobarSavedDateInput = document.getElementById("removeInfobarSavedDateInput");
 const confirmInfobarInput = document.getElementById("confirmInfobarInput");
 const autoCloseInput = document.getElementById("autoCloseInput");
@@ -762,6 +762,7 @@ infobarTemplateLabel.textContent = browser.i18n.getMessage("optionInfobarTemplat
 blockMixedContentLabel.textContent = browser.i18n.getMessage("optionBlockMixedContent");
 saveOriginalURLsLabel.textContent = browser.i18n.getMessage("optionSaveOriginalURLs");
 includeInfobarLabel.textContent = browser.i18n.getMessage("optionIncludeInfobar");
+openInfobarLabel.textContent = browser.i18n.getMessage("optionOpenInfobar");
 removeInfobarSavedDateLabel.textContent = browser.i18n.getMessage("optionRemoveInfobarSavedDate");
 confirmInfobarLabel.textContent = browser.i18n.getMessage("optionConfirmInfobar");
 autoCloseLabel.textContent = browser.i18n.getMessage("optionAutoClose");
@@ -1085,6 +1086,7 @@ async function refresh(profileName) {
 	blockMixedContentInput.checked = profileOptions.blockMixedContent;
 	saveOriginalURLsInput.checked = profileOptions.saveOriginalURLs;
 	includeInfobarInput.checked = profileOptions.includeInfobar;
+	openInfobarInput.checked = profileOptions.openInfobar;
 	removeInfobarSavedDateInput.checked = profileOptions.removeSavedDate;
 	confirmInfobarInput.checked = profileOptions.confirmInfobarContent;
 	autoCloseInput.checked = profileOptions.autoClose;
@@ -1203,6 +1205,7 @@ async function update() {
 			blockMixedContent: blockMixedContentInput.checked,
 			saveOriginalURLs: saveOriginalURLsInput.checked,
 			includeInfobar: includeInfobarInput.checked,
+			openInfobar: openInfobarInput.checked,
 			removeSavedDate: removeInfobarSavedDateInput.checked,
 			confirmInfobarContent: confirmInfobarInput.checked,
 			autoClose: autoCloseInput.checked,

+ 6 - 3
src/ui/content/content-ui-editor-web.js

@@ -981,7 +981,7 @@ pre code {
 
 	let NOTES_WEB_STYLESHEET, MASK_WEB_STYLESHEET, HIGHLIGHTS_WEB_STYLESHEET;
 	let selectedNote, anchorElement, maskNoteElement, maskPageElement, highlightSelectionMode, removeHighlightMode, resizingNoteMode, movingNoteMode, highlightColor, collapseNoteTimeout, cuttingOuterMode, cuttingMode, cuttingTouchTarget, cuttingPath, cuttingPathIndex, previousContent;
-	let removedElements = [], removedElementIndex = 0, initScriptContent, pageResources, pageUrl, pageCompressContent, includeInfobar;
+	let removedElements = [], removedElementIndex = 0, initScriptContent, pageResources, pageUrl, pageCompressContent, includeInfobar, openInfobar;
 
 	globalThis.zip = singlefile.helper.zip;
 	initEventListeners();
@@ -1077,6 +1077,7 @@ pre code {
 			if (message.method == "getContent") {
 				onUpdate(true);
 				includeInfobar = message.includeInfobar;
+				openInfobar = message.openInfobar;
 				let content = getContent(message.compressHTML, message.updatedResources);
 				if (initScriptContent) {
 					content = content.replace(/<script data-template-shadow-root src.*?<\/script>/g, initScriptContent);
@@ -1131,7 +1132,7 @@ pre code {
 				printPage();
 			}
 			if (message.method == "displayInfobar") {
-				singlefile.helper.displayIcon(document, true);
+				singlefile.helper.displayIcon(document, true, { openInfobar: message.openInfobar });
 				const infobarDoc = document.implementation.createHTMLDocument();
 				infobarDoc.body.appendChild(document.querySelector(singlefile.helper.INFOBAR_TAGNAME));
 				serializeShadowRoots(infobarDoc.body);
@@ -2088,7 +2089,9 @@ pre code {
 		});
 		doc.querySelectorAll("." + MASK_CLASS + ", " + singlefile.helper.INFOBAR_TAGNAME + ", ." + REMOVED_CONTENT_CLASS).forEach(element => element.remove());
 		if (includeInfobar) {
-			singlefile.helper.appendInfobar(doc, singlefile.helper.extractInfobarData(doc));
+			const options = singlefile.helper.extractInfobarData(doc);
+			options.openInfobar = openInfobar;
+			singlefile.helper.appendInfobar(doc, options);
 		}
 		doc.querySelectorAll("." + HIGHLIGHT_CLASS).forEach(noteElement => noteElement.classList.remove(HIGHLIGHT_HIDDEN_CLASS));
 		doc.querySelectorAll(`template[${SHADOWROOT_ATTRIBUTE_NAME}]`).forEach(templateElement => {

+ 6 - 3
src/ui/pages/help.html

@@ -329,9 +329,12 @@
 					</li>
 					<li data-options-label="includeInfobarLabel"> <span class="option"></span>Option: include infobar in
 						the saved page</span>
-						<p>Check this
-							option to display the ℹ button at the top right of the page when viewing a saved page in a
-							browser where SingleFile is not installed.</p>
+						<p>Check this option to display the ℹ button at the top right of the page when viewing a saved
+							page in a browser where SingleFile is not installed.</p>
+					</li>
+					<li data-options-label="openInfobarLabel"> <span class="option"></span>Option: keep infobar
+						open</span>
+						<p>Check this option to keep the infobar open when viewing a saved page.</p>
 					</li>
 				</ul>
 				<p>Stylesheets</p>

+ 4 - 0
src/ui/pages/options.html

@@ -179,6 +179,10 @@
 				<label for="includeInfobarInput" id="includeInfobarLabel"></label>
 				<input type="checkbox" id="includeInfobarInput">
 			</div>
+			<div class="option">
+				<label for="openInfobarInput" id="openInfobarLabel"></label>
+				<input type="checkbox" id="openInfobarInput">
+			</div>
 		</details>
 		<details>
 			<summary id="stylesheetsLabel"></summary>