Bläddra i källkod

fixed button refreshing with autosave active

Gildas 7 år sedan
förälder
incheckning
0d846a31aa
2 ändrade filer med 6 tillägg och 6 borttagningar
  1. 4 4
      extension/ui/bg/ui-button.js
  2. 2 2
      lib/single-file/single-file-core.js

+ 4 - 4
extension/ui/bg/ui-button.js

@@ -43,7 +43,7 @@ singlefile.ui.button = (() => {
 		await onTabActivated(tab);
 	});
 	browser.tabs.onCreated.addListener(onTabActivated);
-	browser.tabs.onUpdated.addListener(onTabActivated);
+	browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => onTabActivated(tab));
 	browser.runtime.onMessage.addListener((request, sender) => {
 		if (request.processProgress) {
 			if (request.maxIndex) {
@@ -65,7 +65,7 @@ singlefile.ui.button = (() => {
 		onProgress,
 		onEnd,
 		onError,
-		refresh: (tabId, options) => refresh(tabId, getProperties(tabId, options, "", DEFAULT_COLOR))
+		refresh: (tabId, options) => refresh(tabId, getProperties(tabId, options))
 	};
 
 	function onInitialize(tabId, options, step) {
@@ -88,7 +88,7 @@ singlefile.ui.button = (() => {
 
 	async function onTabActivated(tab) {
 		const autoSave = await singlefile.ui.autosave.isEnabled(tab.id);
-		await refresh(tab.id, getProperties(tab.id, { autoSave }, "", DEFAULT_COLOR));
+		await refresh(tab.id, getProperties(tab.id, { autoSave }));
 		if (singlefile.ui.isAllowedURL(tab.url) && browser.browserAction && browser.browserAction.enable && browser.browserAction.disable) {
 			if (singlefile.ui.isAllowedURL(tab.url)) {
 				try {
@@ -109,7 +109,7 @@ singlefile.ui.button = (() => {
 	function getProperties(tabId, options, text, color, title = DEFAULT_TITLE, path = DEFAULT_ICON_PATH, progress = -1, barProgress = -1, autoColor = [208, 208, 208, 255]) {
 		return {
 			text: options.autoSave ? "[A]" : (text || ""),
-			color: options.autoSave ? autoColor : color,
+			color: options.autoSave ? autoColor : color || DEFAULT_COLOR,
 			title: options.autoSave ? "Autosave active" : title,
 			path: options.autoSave ? DEFAULT_ICON_PATH : path,
 			progress: options.autoSave ? - 1 : progress,

+ 2 - 2
lib/single-file/single-file-core.js

@@ -118,7 +118,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 				this.processor.removeHiddenElements(this.options.sessionId);
 			}
 			const initializationPromises = [this.processor.inlineStylesheets(true), this.processor.linkStylesheets(), this.processor.attributeStyles(true)];
-			if (!this.options.removeFrames) {
+			if (!this.options.removeFrames && this.options.framesData) {
 				initializationPromises.push(this.processor.frames(true));
 			}
 			if (!this.options.removeImports) {
@@ -159,7 +159,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 			if (this.options.removeAlternativeFonts) {
 				this.processor.removeAlternativeFonts(true);
 			}
-			if (!this.options.removeFrames) {
+			if (!this.options.removeFrames && this.options.framesData) {
 				await this.processor.frames();
 			}
 			if (!this.options.removeImports) {