|
|
@@ -88,6 +88,9 @@ const SingleFileCore = (() => {
|
|
|
if (this.options.removeFrames) {
|
|
|
this.processor.removeFrames();
|
|
|
}
|
|
|
+ if (this.options.removeImports) {
|
|
|
+ this.processor.removeImports();
|
|
|
+ }
|
|
|
if (this.options.removeScripts) {
|
|
|
this.processor.removeScripts();
|
|
|
}
|
|
|
@@ -110,10 +113,13 @@ const SingleFileCore = (() => {
|
|
|
if (this.options.removeUnusedCSSRules) {
|
|
|
this.processor.removeUnusedCSSRules();
|
|
|
}
|
|
|
- const initializationPromises = [this.processor.inlineStylesheets(true), this.processor.linkStylesheets(), this.processor.attributeStyles(true), this.processor.linkRelImport(true)];
|
|
|
+ const initializationPromises = [this.processor.inlineStylesheets(true), this.processor.linkStylesheets(), this.processor.attributeStyles(true)];
|
|
|
if (!this.options.removeFrames) {
|
|
|
initializationPromises.push(this.processor.frames(true));
|
|
|
}
|
|
|
+ if (!this.options.removeImports) {
|
|
|
+ initializationPromises.push(this.processor.htmlImports(true));
|
|
|
+ }
|
|
|
await Promise.all(initializationPromises);
|
|
|
this.pendingPromises = [this.processor.inlineStylesheets(), this.processor.attributeStyles(), this.processor.pageResources()];
|
|
|
if (!this.options.removeScripts) {
|
|
|
@@ -145,7 +151,9 @@ const SingleFileCore = (() => {
|
|
|
if (!this.options.removeFrames) {
|
|
|
await this.processor.frames();
|
|
|
}
|
|
|
- await this.processor.linkRelImport();
|
|
|
+ if (!this.options.removeImports) {
|
|
|
+ await this.processor.htmlImports();
|
|
|
+ }
|
|
|
if (this.onprogress) {
|
|
|
this.onprogress(new ProgressEvent(PAGE_ENDED, { pageURL: this.options.url }));
|
|
|
}
|
|
|
@@ -293,6 +301,10 @@ const SingleFileCore = (() => {
|
|
|
this.doc.querySelectorAll("iframe, frame").forEach(element => element.remove());
|
|
|
}
|
|
|
|
|
|
+ removeImports() {
|
|
|
+ this.doc.querySelectorAll("link[rel=import]").forEach(element => element.remove());
|
|
|
+ }
|
|
|
+
|
|
|
resetCharsetMeta() {
|
|
|
this.doc.querySelectorAll("meta[charset]").forEach(element => element.remove());
|
|
|
const metaElement = this.doc.createElement("meta");
|
|
|
@@ -486,7 +498,7 @@ const SingleFileCore = (() => {
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
- async linkRelImport(initialization) {
|
|
|
+ async htmlImports(initialization) {
|
|
|
let linkElements = this.doc.querySelectorAll("link[rel=import][href]");
|
|
|
linkElements = DomUtil.removeNoScriptFrames(linkElements);
|
|
|
if (!this.relImportProcessors) {
|