Selaa lähdekoodia

added an option to append the save date to the filename

Gildas 7 vuotta sitten
vanhempi
sitoutus
8b8ee80234

+ 6 - 1
extension/core/scripts/bg/config.js

@@ -36,6 +36,10 @@ singlefile.config = (() => {
 			config.contextMenuEnabled = true;
 			localStorage.config = JSON.stringify(config);
 		}
+		if (config.appendSaveDate == undefined) {
+			config.appendSaveDate = true;
+			localStorage.config = JSON.stringify(config);
+		}
 	}
 
 	return {
@@ -49,7 +53,8 @@ singlefile.config = (() => {
 				removeFrames: true,
 				removeScripts: true,
 				rawDocument: false,
-				compressHTML: true
+				compressHTML: true,
+				appendSaveDate: true
 			};
 		},
 		reset() {

+ 1 - 1
extension/core/scripts/content/content.js

@@ -40,7 +40,7 @@
 				})
 				.then(page => {
 					const date = new Date();
-					page.filename = page.title + " (" + date.toISOString().split("T")[0] + " " + date.toLocaleTimeString() + ")" + ".html";
+					page.filename = page.title + (request.options.appendSaveDate ? " (" + date.toISOString().split("T")[0] + " " + date.toLocaleTimeString() + ")" : "") + ".html";
 					page.url = URL.createObjectURL(new Blob([page.content], { type: "text/html" }));
 					downloadPage(page);
 					singlefile.ui.end();

+ 9 - 1
extension/ui/pages/help.html

@@ -98,9 +98,17 @@
 							<u>check</u> this option</p>
 					</li>
 
+					<li>
+						<span class="option">append save date to the filename</span>
+						<p>Check this option to append the save date of the webpage to the filename.
+						</p>
+						<p class="notice">It is recommended to
+							<u>check</u> this option</p>
+					</li>
+
 					<li>
 						<span class="option">Reset to default options</span>
-						<p>Reset all the options to default state.</p>
+						<p>Reset all the options to their default value.</p>
 					</li>
 				</ul>
 			</li>

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

@@ -39,6 +39,10 @@
 				<label for="contextMenuEnabledInput">add SingleFile entry in the context menu</label>
 				<input type="checkbox" id="contextMenuEnabledInput">
 			</div>
+			<div class="option">
+				<label for="contextMenuEnabledInput">append save date to the filename</label>
+				<input type="checkbox" id="appendSaveDateInput">
+			</div>
 			<div class="option bottom">
 				<a href="help.html" target="SingleFileHelpPage">help</a>
 				<button id="resetButton" title="Reset all the options to default values">Reset</button>

+ 4 - 1
extension/ui/scripts/bg/options.js

@@ -32,6 +32,7 @@
 		const saveRawPageInput = document.getElementById("saveRawPageInput");
 		const compressHTMLInput = document.getElementById("compressHTMLInput");
 		const contextMenuEnabledInput = document.getElementById("contextMenuEnabledInput");
+		const appendSaveDateInput = document.getElementById("appendSaveDateInput");
 		document.getElementById("resetButton").addEventListener("click", () => {
 			bgPage.singlefile.config.reset();
 			refresh();
@@ -49,6 +50,7 @@
 			saveRawPageInput.checked = config.saveRawPage;
 			compressHTMLInput.checked = config.compressHTML;
 			contextMenuEnabledInput.checked = config.contextMenuEnabled;
+			appendSaveDateInput.checked = config.appendSaveDate;
 		}
 
 		function update() {
@@ -59,7 +61,8 @@
 				removeScripts: removeScriptsInput.checked,
 				saveRawPage: saveRawPageInput.checked,
 				compressHTML: compressHTMLInput.checked,
-				contextMenuEnabled: contextMenuEnabledInput.checked
+				contextMenuEnabled: contextMenuEnabledInput.checked,
+				appendSaveDate: appendSaveDateInput.checked
 			});
 			bgPage.singlefile.ui.update();
 		}