|
|
@@ -74,7 +74,6 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
class PageProcessor {
|
|
|
constructor(options) {
|
|
|
this.options = options;
|
|
|
- this.options.content = this.options.content || (this.options.doc ? DOMProcessor.serialize(this.options.doc, false) : null);
|
|
|
this.options.url = this.options.url || this.options.doc.location.href;
|
|
|
this.processor = new DOMProcessor(options);
|
|
|
if (this.options.doc) {
|
|
|
@@ -90,6 +89,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
this.processor.markPreservedElements();
|
|
|
}
|
|
|
}
|
|
|
+ this.options.content = this.options.content || (this.options.doc ? DOMProcessor.serialize(this.options.doc, false) : null);
|
|
|
this.onprogress = options.onprogress || (() => { });
|
|
|
}
|
|
|
|
|
|
@@ -242,6 +242,29 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
// ------------
|
|
|
const ESCAPED_FRAGMENT = "_escaped_fragment_=";
|
|
|
const EMPTY_DATA_URI = "data:base64,";
|
|
|
+ const STATS_DEFAULT_VALUES = {
|
|
|
+ discarded: {
|
|
|
+ htmlBytes: 0,
|
|
|
+ hiddenElements: 0,
|
|
|
+ imports: 0,
|
|
|
+ scripts: 0,
|
|
|
+ objects: 0,
|
|
|
+ audioSource: 0,
|
|
|
+ videoSource: 0,
|
|
|
+ frames: 0,
|
|
|
+ cssRules: 0
|
|
|
+ },
|
|
|
+ processed: {
|
|
|
+ htmlBytes: 0,
|
|
|
+ imports: 0,
|
|
|
+ scripts: 0,
|
|
|
+ frames: 0,
|
|
|
+ cssRules: 0,
|
|
|
+ canvas: 0,
|
|
|
+ styleSheets: 0,
|
|
|
+ resources: 0
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
const batchRequest = new BatchRequest();
|
|
|
|
|
|
@@ -249,36 +272,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
constructor(options) {
|
|
|
this.options = options;
|
|
|
if (this.options.displayStats) {
|
|
|
- this.stats = {
|
|
|
- discarded: {
|
|
|
- htmlBytes: 0,
|
|
|
- hiddenElements: 0,
|
|
|
- imports: 0,
|
|
|
- scripts: 0,
|
|
|
- objects: 0,
|
|
|
- audioSource: 0,
|
|
|
- videoSource: 0,
|
|
|
- frames: 0,
|
|
|
- cssRules: 0,
|
|
|
- canvas: 0,
|
|
|
- styleSheets: 0,
|
|
|
- resources: 0
|
|
|
- },
|
|
|
- processed: {
|
|
|
- htmlBytes: 0,
|
|
|
- hiddenElements: 0,
|
|
|
- imports: 0,
|
|
|
- scripts: 0,
|
|
|
- objects: 0,
|
|
|
- audioSource: 0,
|
|
|
- videoSource: 0,
|
|
|
- frames: 0,
|
|
|
- cssRules: 0,
|
|
|
- canvas: 0,
|
|
|
- styleSheets: 0,
|
|
|
- resources: 0
|
|
|
- }
|
|
|
- };
|
|
|
+ this.stats = JSON.parse(JSON.stringify(STATS_DEFAULT_VALUES));
|
|
|
}
|
|
|
this.baseURI = options.url;
|
|
|
}
|
|
|
@@ -541,6 +535,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
|
|
|
removeHiddenElements() {
|
|
|
const hiddenElements = this.doc.querySelectorAll("[" + REMOVED_CONTENT_ATTRIBUTE_NAME + "]");
|
|
|
+ debugger
|
|
|
if (this.options.displayStats) {
|
|
|
this.stats.discarded.hiddenElements = hiddenElements.length;
|
|
|
}
|