Просмотр исходного кода

added tab-index variable (fixes #135)

Gildas 7 лет назад
Родитель
Сommit
99ccade315

+ 1 - 0
extension/core/bg/autosave.js

@@ -98,6 +98,7 @@ singlefile.autosave = (() => {
 		options.autoSave = true;
 		options.autoSave = true;
 		options.incognito = tab.incognito;
 		options.incognito = tab.incognito;
 		options.tabId = tabId;
 		options.tabId = tabId;
+		options.tabIndex = tab.index;
 		let index = 0, maxIndex = 0;
 		let index = 0, maxIndex = 0;
 		options.onprogress = async event => {
 		options.onprogress = async event => {
 			if (event.type == event.RESOURCES_INITIALIZED) {
 			if (event.type == event.RESOURCES_INITIALIZED) {

+ 1 - 0
extension/core/bg/core.js

@@ -72,6 +72,7 @@ singlefile.core = (() => {
 			await initScripts();
 			await initScripts();
 			const tabId = tab.id;
 			const tabId = tab.id;
 			options.tabId = tabId;
 			options.tabId = tabId;
+			options.tabIndex = tab.index;
 			try {
 			try {
 				if (options.autoSave) {
 				if (options.autoSave) {
 					const options = await singlefile.config.getOptions(tab.url, true);
 					const options = await singlefile.config.getOptions(tab.url, true);

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

@@ -454,6 +454,7 @@
 					<li><code>{url-hash}</code>: the hash of the URL (e.g. "chapter-2")</li>
 					<li><code>{url-hash}</code>: the hash of the URL (e.g. "chapter-2")</li>
 					<li><code>{url-referrer}</code>: the URI of the page that "linked" to the page (e.g. "http_example.com")</li>
 					<li><code>{url-referrer}</code>: the URI of the page that "linked" to the page (e.g. "http_example.com")</li>
 					<li><code>{tab-id}</code>: the unique identifier of the tab (e.g. "326")</li>
 					<li><code>{tab-id}</code>: the unique identifier of the tab (e.g. "326")</li>
+					<li><code>{tab-index}</code>: the index of the tab in the window (e.g. "1")</li>
 					<li><code>{digest-sha-256}</code>: the SHA-256 hash value of the entire page content (e.g.
 					<li><code>{digest-sha-256}</code>: the SHA-256 hash value of the entire page content (e.g.
 						e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855)</li>
 						e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855)</li>
 					<li><code>{digest-sha-384}</code>: the SHA-384 hash value of the entire page content</li>
 					<li><code>{digest-sha-384}</code>: the SHA-384 hash value of the entire page content</li>

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

@@ -1160,6 +1160,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 			template = template.replace(/{\s*url-search-[^}\s]*\s*}/gi, "");
 			template = template.replace(/{\s*url-search-[^}\s]*\s*}/gi, "");
 			template = await Util.evalTemplateVariable(template, "url-username", () => url.username || "No username", dontReplaceSlash);
 			template = await Util.evalTemplateVariable(template, "url-username", () => url.username || "No username", dontReplaceSlash);
 			template = await Util.evalTemplateVariable(template, "tab-id", () => String(options.tabId || "No tab id"), dontReplaceSlash);
 			template = await Util.evalTemplateVariable(template, "tab-id", () => String(options.tabId || "No tab id"), dontReplaceSlash);
+			template = await Util.evalTemplateVariable(template, "tab-index", () => String(options.tabIndex || "No tab index"), dontReplaceSlash);
 			template = await Util.evalTemplateVariable(template, "url-last-segment", () => decodeURI(Util.getLastSegment(url)) || "No last segment", dontReplaceSlash);
 			template = await Util.evalTemplateVariable(template, "url-last-segment", () => decodeURI(Util.getLastSegment(url)) || "No last segment", dontReplaceSlash);
 			if (content) {
 			if (content) {
 				template = await Util.evalTemplateVariable(template, "digest-sha-256", async () => docUtil.digest("SHA-256", content), dontReplaceSlash);
 				template = await Util.evalTemplateVariable(template, "digest-sha-256", async () => docUtil.digest("SHA-256", content), dontReplaceSlash);