|
|
@@ -76,7 +76,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
if (this.options.doc) {
|
|
|
const docData = DOM.preProcessDoc(this.options.doc, this.options.win, this.options);
|
|
|
this.options.canvasData = docData.canvasData;
|
|
|
- this.options.emptyStyleRulesText = docData.emptyStyleRulesText;
|
|
|
+ this.options.stylesheetContents = docData.stylesheetContents;
|
|
|
}
|
|
|
this.options.content = this.options.content || (this.options.doc ? DOM.serialize(this.options.doc, false) : null);
|
|
|
this.onprogress = options.onprogress || (() => { });
|
|
|
@@ -91,7 +91,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
async initialize() {
|
|
|
this.onprogress(new ProgressEvent(RESOURCES_INITIALIZING, { pageURL: this.options.url }));
|
|
|
this.processor.removeUIElements();
|
|
|
- this.processor.replaceEmptyStyles();
|
|
|
+ this.processor.replaceStyleContents();
|
|
|
if (!this.options.jsEnabled || (this.options.saveRawPage && this.options.removeScripts)) {
|
|
|
this.processor.insertNoscriptContents();
|
|
|
}
|
|
|
@@ -481,14 +481,12 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- replaceEmptyStyles() {
|
|
|
- if (this.options.emptyStyleRulesText) {
|
|
|
+ replaceStyleContents() {
|
|
|
+ if (this.options.stylesheetContents) {
|
|
|
let indexStyle = 0;
|
|
|
this.doc.querySelectorAll("style").forEach(styleElement => {
|
|
|
- if (!styleElement.textContent) {
|
|
|
- styleElement.textContent = this.options.emptyStyleRulesText[indexStyle];
|
|
|
- indexStyle++;
|
|
|
- }
|
|
|
+ styleElement.textContent = this.options.stylesheetContents[indexStyle];
|
|
|
+ indexStyle++;
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
@@ -563,7 +561,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
if (frameData.content) {
|
|
|
options.content = frameData.content;
|
|
|
options.canvasData = frameData.canvasData;
|
|
|
- options.emptyStyleRulesText = frameData.emptyStyleRulesText;
|
|
|
+ options.stylesheetContents = frameData.stylesheetContents;
|
|
|
frameData.processor = new PageProcessor(options);
|
|
|
frameData.frameElement = frameElement;
|
|
|
await frameData.processor.loadPage();
|