|
|
@@ -36,26 +36,25 @@ this.singlefile = this.singlefile || {
|
|
|
},
|
|
|
vendor: {},
|
|
|
modules: {},
|
|
|
- async initializeOptions(options = {}, doc = window.document, win = window) {
|
|
|
- this.helper.initDoc(doc);
|
|
|
- const preInitializationPromises = [];
|
|
|
- if (!options.saveRawPage) {
|
|
|
- if (!options.removeFrames) {
|
|
|
- preInitializationPromises.push(this.frameTree.content.frames.getAsync(options));
|
|
|
- }
|
|
|
- if (options.loadDeferredImages) {
|
|
|
- preInitializationPromises.push(this.lazy.content.loader.process(options));
|
|
|
+ async getPageData(options = {}, initOptions, doc = window.document, win = window) {
|
|
|
+ this.main.init(initOptions);
|
|
|
+ if (doc && window) {
|
|
|
+ this.helper.initDoc(doc);
|
|
|
+ const preInitializationPromises = [];
|
|
|
+ if (!options.saveRawPage) {
|
|
|
+ if (!options.removeFrames) {
|
|
|
+ preInitializationPromises.push(this.frameTree.content.frames.getAsync(options));
|
|
|
+ }
|
|
|
+ if (options.loadDeferredImages) {
|
|
|
+ preInitializationPromises.push(this.lazy.content.loader.process(options));
|
|
|
+ }
|
|
|
}
|
|
|
+ [options.frames] = await Promise.all(preInitializationPromises);
|
|
|
}
|
|
|
- [options.frames] = await Promise.all(preInitializationPromises);
|
|
|
options.doc = doc;
|
|
|
options.win = win;
|
|
|
- return options;
|
|
|
- },
|
|
|
- async getPageData(options = {}, initOptions) {
|
|
|
options.insertSingleFileComment = true;
|
|
|
options.insertFaviconLink = true;
|
|
|
- this.main.init(initOptions);
|
|
|
const singleFile = new this.SingleFile(options);
|
|
|
await singleFile.run();
|
|
|
return await singleFile.getPageData();
|