ソースを参照

fix error when running from CLI

Gildas 5 年 前
コミット
babcbf9306

+ 10 - 8
lib/single-file/processors/lazy/content/content-lazy-loader.js

@@ -35,15 +35,17 @@ this.singlefile.lib.processors.lazy.content.loader = this.singlefile.lib.process
 	const removeEventListener = (type, listener, options) => window.removeEventListener(type, listener, options);
 	const timeouts = new Map();
 
-	browser.runtime.onMessage.addListener(message => {
-		if (message.method == "singlefile.lazyTimeout.onTimeout") {
-			const timeoutData = timeouts.get(message.type);
-			if (timeoutData) {
-				timeouts.delete(message.type);
-				timeoutData.callback();
+	if (browser && browser.runtime) {
+		browser.runtime.onMessage.addListener(message => {
+			if (message.method == "singlefile.lazyTimeout.onTimeout") {
+				const timeoutData = timeouts.get(message.type);
+				if (timeoutData) {
+					timeouts.delete(message.type);
+					timeoutData.callback();
+				}
 			}
-		}
-	});
+		});
+	}
 
 	return {
 		process: async options => {