فهرست منبع

add {profile-name} variable (fix #594)

Gildas 5 سال پیش
والد
کامیت
1b5cb05fbd
2فایلهای تغییر یافته به همراه5 افزوده شده و 2 حذف شده
  1. 4 2
      extension/core/bg/config.js
  2. 1 0
      lib/single-file/single-file-core.js

+ 4 - 2
extension/core/bg/config.js

@@ -280,12 +280,14 @@ singlefile.extension.core.bg.config = (() => {
 	async function getOptions(url, autoSave) {
 		const [config, rule, tabsData] = await Promise.all([getConfig(), getRule(url), singlefile.extension.core.bg.tabsData.get()]);
 		const tabProfileName = tabsData.profileName || DEFAULT_PROFILE_NAME;
+		let selectedProfileName;
 		if (rule) {
 			const profileName = rule[autoSave ? "autoSaveProfile" : "profile"];
-			return config.profiles[profileName == CURRENT_PROFILE_NAME ? tabProfileName : profileName];
+			selectedProfileName = profileName == CURRENT_PROFILE_NAME ? tabProfileName : profileName;
 		} else {
-			return config.profiles[tabProfileName];
+			selectedProfileName = tabProfileName;
 		}
+		return Object.assign({ profileName: selectedProfileName }, config.profiles[selectedProfileName]);
 	}
 
 	async function updateProfile(profileName, profile) {

+ 1 - 0
lib/single-file/single-file-core.js

@@ -1501,6 +1501,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			const bookmarkFolder = (options.bookmarkFolders && options.bookmarkFolders.join("/")) || "";
 			template = await evalTemplateVariable(template, "bookmark-pathname", () => bookmarkFolder, dontReplaceSlash === undefined ? true : dontReplaceSlash, options.filenameReplacementCharacter);
 			template = await evalTemplateVariable(template, "bookmark-pathname-flat", () => bookmarkFolder, false, options.filenameReplacementCharacter);
+			template = await evalTemplateVariable(template, "profile-name", () => options.profileName, dontReplaceSlash, options.filenameReplacementCharacter);
 			return template.trim();
 
 			function decode(value) {