|
|
@@ -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 => {
|