|
@@ -18,11 +18,11 @@
|
|
|
* along with SingleFile. If not, see <http://www.gnu.org/licenses/>.
|
|
* along with SingleFile. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-/* global singlefile, browser, window, addEventListener, removeEventListener, document, location, docHelper */
|
|
|
|
|
|
|
+/* global singlefile, frameTree, browser, window, addEventListener, removeEventListener, document, location, docHelper */
|
|
|
|
|
|
|
|
this.singlefile.autoSaveUnload = this.singlefile.autoSaveUnload || (async () => {
|
|
this.singlefile.autoSaveUnload = this.singlefile.autoSaveUnload || (async () => {
|
|
|
|
|
|
|
|
- let listenerAdded, saveConfig;
|
|
|
|
|
|
|
+ let listenerAdded, options;
|
|
|
refreshAutoSaveUnload();
|
|
refreshAutoSaveUnload();
|
|
|
browser.runtime.onMessage.addListener(message => {
|
|
browser.runtime.onMessage.addListener(message => {
|
|
|
if (message.autoSaveUnloadEnabled) {
|
|
if (message.autoSaveUnloadEnabled) {
|
|
@@ -33,7 +33,7 @@ this.singlefile.autoSaveUnload = this.singlefile.autoSaveUnload || (async () =>
|
|
|
|
|
|
|
|
async function refreshAutoSaveUnload() {
|
|
async function refreshAutoSaveUnload() {
|
|
|
const [autoSaveEnabled, config] = await Promise.all([browser.runtime.sendMessage({ isAutoSaveEnabled: true }), browser.runtime.sendMessage({ getConfig: true })]);
|
|
const [autoSaveEnabled, config] = await Promise.all([browser.runtime.sendMessage({ isAutoSaveEnabled: true }), browser.runtime.sendMessage({ getConfig: true })]);
|
|
|
- saveConfig = config;
|
|
|
|
|
|
|
+ options = config;
|
|
|
enableAutoSaveUnload(autoSaveEnabled && (config.autoSaveUnload || config.autoSaveLoadOrUnload));
|
|
enableAutoSaveUnload(autoSaveEnabled && (config.autoSaveUnload || config.autoSaveLoadOrUnload));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -51,8 +51,8 @@ this.singlefile.autoSaveUnload = this.singlefile.autoSaveUnload || (async () =>
|
|
|
|
|
|
|
|
function onUnload() {
|
|
function onUnload() {
|
|
|
if (!singlefile.pageAutoSaved) {
|
|
if (!singlefile.pageAutoSaved) {
|
|
|
- const docData = docHelper.preProcessDoc(document, window, saveConfig);
|
|
|
|
|
- browser.runtime.sendMessage({ processContent: true, content: docHelper.serialize(document), canvasData: docData.canvasData, emptyStyleRulesText: docData.emptyStyleRulesText, url: location.href });
|
|
|
|
|
|
|
+ const docData = docHelper.preProcessDoc(document, window, options);
|
|
|
|
|
+ browser.runtime.sendMessage({ processContent: true, content: docHelper.serialize(document), canvasData: docData.canvasData, emptyStyleRulesText: docData.emptyStyleRulesText, framesData: this.frameTree && !options.removeFrames && frameTree.getSync(options), url: location.href });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|