Skip to content

Commit

Permalink
add Infobar > keep infobar open option (fix #1516, see #1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
gildas-lormeau committed Jul 29, 2024
1 parent ec265ba commit 6d00e15
Show file tree
Hide file tree
Showing 23 changed files with 90 additions and 11 deletions.
4 changes: 4 additions & 0 deletions _locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/it/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/nl_NL/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/pl/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/pt_PT/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/pt_br/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/tr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/uk/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 4 additions & 0 deletions _locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
1 change: 1 addition & 0 deletions src/core/bg/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions src/core/bg/downloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/core/common/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/ui/bg/ui-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -545,7 +546,8 @@ function savePage() {

function displayInfobar() {
editorElement.contentWindow.postMessage(JSON.stringify({
method: "displayInfobar"
method: "displayInfobar",
openInfobar: tabData.options.openInfobar
}), "*");
}

Expand Down
7 changes: 5 additions & 2 deletions src/ui/bg/ui-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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==";
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 6 additions & 3 deletions src/ui/content/content-ui-editor-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 => {
Expand Down
9 changes: 6 additions & 3 deletions src/ui/pages/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,12 @@ <h4>Save a complete page into a single HTML file</h4>
</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>
Expand Down
4 changes: 4 additions & 0 deletions src/ui/pages/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ <h3>
<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>
Expand Down

0 comments on commit 6d00e15

Please sign in to comment.