|
|
@@ -80,6 +80,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
sequential: [
|
|
|
{ action: "repairDocument" },
|
|
|
{ action: "replaceStyleContents" },
|
|
|
+ { option: "selected", action: "removeUnselectedContent" },
|
|
|
{ option: "removeVideoSrc", action: "insertVideoPosters" },
|
|
|
{ option: "removeAlternativeImages", action: "removeAlternativeImages" },
|
|
|
{ option: "removeFrames", action: "removeFrames" },
|
|
|
@@ -158,6 +159,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
|
|
|
async initialize() {
|
|
|
this.onprogress(new ProgressEvent(RESOURCES_INITIALIZING, { pageURL: this.options.url }));
|
|
|
+
|
|
|
await this.executeStage(0);
|
|
|
this.pendingPromises = this.executeStage(1);
|
|
|
if (this.options.doc) {
|
|
|
@@ -307,14 +309,6 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
|
|
|
async getPageData() {
|
|
|
DOM.postProcessDoc(this.doc, this.options);
|
|
|
- if (this.options.selected) {
|
|
|
- const rootElement = this.doc.querySelector("[" + SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME + "]");
|
|
|
- if (rootElement) {
|
|
|
- DomProcessorHelper.isolateElements(rootElement);
|
|
|
- rootElement.removeAttribute(SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME);
|
|
|
- rootElement.removeAttribute(SELECTED_CONTENT_ATTRIBUTE_NAME);
|
|
|
- }
|
|
|
- }
|
|
|
const titleElement = this.doc.querySelector("title");
|
|
|
this.options.title = titleElement ? titleElement.textContent.trim() : "";
|
|
|
this.options.info = {};
|
|
|
@@ -348,6 +342,15 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ removeUnselectedContent() {
|
|
|
+ const rootElement = this.doc.querySelector("[" + SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME + "]");
|
|
|
+ if (rootElement) {
|
|
|
+ DomProcessorHelper.isolateElements(rootElement);
|
|
|
+ rootElement.removeAttribute(SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME);
|
|
|
+ rootElement.removeAttribute(SELECTED_CONTENT_ATTRIBUTE_NAME);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
setInputValues() {
|
|
|
this.doc.querySelectorAll("input").forEach(input => {
|
|
|
const value = input.getAttribute(DOM.inputValueAttributeName(this.options.sessionId));
|