Browse Source

ensure the extension works just after install without refreshing the current page

Gildas 7 years ago
parent
commit
45f1bde1ae
5 changed files with 5 additions and 13 deletions
  1. 0 1
      README.MD
  2. 3 4
      extension/core/bg/bg.js
  3. 1 1
      extension/core/content/content.js
  4. 1 5
      extension/ui/bg/ui.js
  5. 0 2
      extension/ui/pages/help.html

+ 0 - 1
README.MD

@@ -35,7 +35,6 @@ See the extension help in the options page for more detailed information about t
 
 ## Known Issues
 - All browsers:
-  - After installing the extension, if you want to save a tab that was already opened then you need to refresh it first.
   - For security reasons, you cannot save pages hosted on https://chrome.google.com or https://addons.mozilla.org.
   - Frame contents cannot be saved when "auto-save on page unload" option is checked.
 - Chrome/Opera:

+ 3 - 4
extension/core/bg/bg.js

@@ -22,9 +22,10 @@
 
 singlefile.core = (() => {
 
-	const TIMEOUT_PROCESS_START_MESSAGE = 10000;
-
 	const contentScriptFiles = [
+		"lib/browser-polyfill/custom-browser-polyfill.js",
+		"/extension/index.js",
+		"/lib/single-file/doc-helper.js",
 		"/extension/ui/content/ui.js",
 		"/lib/single-file/base64.js",
 		"/lib/single-file/uglifycss.js",
@@ -66,13 +67,11 @@ singlefile.core = (() => {
 			Object.keys(processOptions).forEach(key => options[key] = processOptions[key]);
 			return new Promise(async (resolve, reject) => {
 				const processPromise = processStart(tab, options);
-				const errorTimeout = setTimeout(reject, TIMEOUT_PROCESS_START_MESSAGE);
 				try {
 					await processPromise;
 				} catch (error) {
 					reject(error);
 				}
-				clearTimeout(errorTimeout);
 				resolve();
 			});
 		}

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

@@ -77,7 +77,7 @@ this.singlefile.top = this.singlefile.top || (() => {
 		options.insertSingleFileComment = true;
 		options.insertFaviconLink = true;
 		options.jsEnabled = true;
-		if (!options.removeFrames) {
+		if (!options.removeFrames && this.frameTree) {
 			options.framesData = await frameTree.get(options);
 		}
 		options.doc = document;

+ 1 - 5
extension/ui/bg/ui.js

@@ -286,11 +286,7 @@ singlefile.ui = (() => {
 			await singlefile.core.processTab(tab, options);
 			refreshBadge(tabId, getBadgeProperties(tabId, options, "...", [4, 229, 36, 255], "Initializing SingleFile (2/2)"));
 		} catch (error) {
-			if (error) {
-				onTabError(tabId, options);
-			} else {
-				refreshBadge(tabId, getBadgeProperties(tabId, options, "↻", [255, 141, 1, 255]));
-			}
+			onTabError(tabId, options);
 		}
 	}
 

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

@@ -297,8 +297,6 @@
 					<li>
 						All browsers
 						<ul>
-							<li>After installing the extension, if you want to save a tab that was already opened then you need to refresh it first.
-							</li>
 							<li>For security reasons, you cannot save pages hosted on https://chrome.google.com or https://addons.mozilla.org.</li>
 							<li>Frame contents cannot be saved when "auto-save on page unload" option is checked.</li>
 						</ul>