|
@@ -27,6 +27,8 @@ this.singlefile.extension.core.content.bootstrap = this.singlefile.extension.cor
|
|
|
|
|
|
|
|
const singlefile = this.singlefile;
|
|
const singlefile = this.singlefile;
|
|
|
|
|
|
|
|
|
|
+ const PUSH_STATE_NOTIFICATION_EVENT_NAME = "single-file-push-state";
|
|
|
|
|
+
|
|
|
let unloadListenerAdded, options, autoSaveEnabled, autoSaveTimeout, autoSavingPage, pageAutoSaved;
|
|
let unloadListenerAdded, options, autoSaveEnabled, autoSaveTimeout, autoSavingPage, pageAutoSaved;
|
|
|
singlefile.extension.core.content.updatedResources = {};
|
|
singlefile.extension.core.content.updatedResources = {};
|
|
|
browser.runtime.sendMessage({ method: "autosave.init" }).then(message => {
|
|
browser.runtime.sendMessage({ method: "autosave.init" }).then(message => {
|
|
@@ -36,7 +38,7 @@ this.singlefile.extension.core.content.bootstrap = this.singlefile.extension.cor
|
|
|
});
|
|
});
|
|
|
browser.runtime.onMessage.addListener(message => { onMessage(message); });
|
|
browser.runtime.onMessage.addListener(message => { onMessage(message); });
|
|
|
browser.runtime.sendMessage({ method: "ui.processInit" });
|
|
browser.runtime.sendMessage({ method: "ui.processInit" });
|
|
|
- addEventListener("single-file-push-state", () => browser.runtime.sendMessage({ method: "ui.processInit" }));
|
|
|
|
|
|
|
+ addEventListener(PUSH_STATE_NOTIFICATION_EVENT_NAME, () => browser.runtime.sendMessage({ method: "ui.processInit" }));
|
|
|
return {};
|
|
return {};
|
|
|
|
|
|
|
|
async function onMessage(message) {
|
|
async function onMessage(message) {
|
|
@@ -95,12 +97,12 @@ this.singlefile.extension.core.content.bootstrap = this.singlefile.extension.cor
|
|
|
if (autoSaveEnabled && options && (options.autoSaveUnload || options.autoSaveLoadOrUnload)) {
|
|
if (autoSaveEnabled && options && (options.autoSaveUnload || options.autoSaveLoadOrUnload)) {
|
|
|
if (!unloadListenerAdded) {
|
|
if (!unloadListenerAdded) {
|
|
|
addEventListener("unload", onUnload);
|
|
addEventListener("unload", onUnload);
|
|
|
- addEventListener("single-file-push-state", onUnload);
|
|
|
|
|
|
|
+ addEventListener(PUSH_STATE_NOTIFICATION_EVENT_NAME, onUnload);
|
|
|
unloadListenerAdded = true;
|
|
unloadListenerAdded = true;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
removeEventListener("unload", onUnload);
|
|
removeEventListener("unload", onUnload);
|
|
|
- removeEventListener("single-file-push-state", onUnload);
|
|
|
|
|
|
|
+ removeEventListener(PUSH_STATE_NOTIFICATION_EVENT_NAME, onUnload);
|
|
|
unloadListenerAdded = false;
|
|
unloadListenerAdded = false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|