Jelajahi Sumber

if unchanged, select the same profile for auto-save than the default one when creating a rule

Gildas 7 tahun lalu
induk
melakukan
fbfb571e93
1 mengubah file dengan 10 tambahan dan 0 penghapusan
  1. 10 0
      extension/ui/bg/ui-options.js

+ 10 - 0
extension/ui/bg/ui-options.js

@@ -133,11 +133,21 @@
 	const showAllProfilesInput = document.getElementById("showAllProfilesInput");
 	const showAutoSaveProfileInput = document.getElementById("showAutoSaveProfileInput");
 	let pendingSave = Promise.resolve();
+	let autoSaveProfileChanged;
+	ruleProfileInput.onchange = () => {
+		if (!autoSaveProfileChanged) {
+			ruleAutoSaveProfileInput.value = ruleProfileInput.value;
+		}
+	};
+	ruleAutoSaveProfileInput.onchange = () => {
+		autoSaveProfileChanged = true;
+	};
 	ruleAddButton.addEventListener("click", async () => {
 		try {
 			await singlefile.config.addRule(ruleUrlInput.value, ruleProfileInput.value, ruleAutoSaveProfileInput.value);
 			ruleUrlInput.value = "";
 			ruleProfileInput.value = ruleAutoSaveProfileInput.value = singlefile.config.DEFAULT_PROFILE_NAME;
+			autoSaveProfileChanged = false;
 			await refresh();
 			ruleUrlInput.focus();
 		} catch (error) {