single-file-cli 1.0.64 → 1.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +0 -0
- package/Dockerfile +0 -0
- package/LICENSE +0 -0
- package/README.MD +0 -0
- package/args.js +0 -0
- package/back-ends/common/scripts.js +0 -0
- package/back-ends/extensions/bypass-csp/index.js +0 -0
- package/back-ends/extensions/bypass-csp/manifest.json +0 -0
- package/back-ends/extensions/disable-web-security/index.js +0 -0
- package/back-ends/extensions/disable-web-security/manifest.json +0 -0
- package/back-ends/extensions/network-idle/bg.js +0 -0
- package/back-ends/extensions/network-idle/content.js +0 -0
- package/back-ends/extensions/network-idle/manifest.json +0 -0
- package/back-ends/extensions/signed/bypass_csp-0.0.3-an+fx.xpi +0 -0
- package/back-ends/extensions/signed/disable_web_security-0.0.3-an+fx.xpi +0 -0
- package/back-ends/extensions/signed/network_idle-0.0.2-an+fx.xpi +0 -0
- package/back-ends/jsdom.js +0 -0
- package/back-ends/playwright-chromium.js +0 -0
- package/back-ends/playwright-firefox.js +0 -0
- package/back-ends/playwright-webkit.js +0 -0
- package/back-ends/puppeteer-firefox.js +0 -0
- package/back-ends/puppeteer.js +0 -0
- package/back-ends/webdriver-chromium.js +172 -172
- package/back-ends/webdriver-gecko.js +0 -0
- package/lib/single-file-bootstrap.js +1 -1
- package/lib/single-file-frames.js +1 -1
- package/lib/single-file-hooks-frames.js +0 -0
- package/lib/single-file.js +1 -1
- package/package.json +40 -40
- package/rollup.config.dev.js +0 -0
- package/rollup.config.js +0 -0
- package/single-file-cli-api.js +0 -0
- package/single-file.bat +0 -0
package/.eslintrc.js
CHANGED
|
File without changes
|
package/Dockerfile
CHANGED
|
File without changes
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.MD
CHANGED
|
File without changes
|
package/args.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/back-ends/jsdom.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/back-ends/puppeteer.js
CHANGED
|
File without changes
|
|
@@ -1,173 +1,173 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2010-2020 Gildas Lormeau
|
|
3
|
-
* contact : gildas.lormeau <at> gmail.com
|
|
4
|
-
*
|
|
5
|
-
* This file is part of SingleFile.
|
|
6
|
-
*
|
|
7
|
-
* The code in this file is free software: you can redistribute it and/or
|
|
8
|
-
* modify it under the terms of the GNU Affero General Public License
|
|
9
|
-
* (GNU AGPL) as published by the Free Software Foundation, either version 3
|
|
10
|
-
* of the License, or (at your option) any later version.
|
|
11
|
-
*
|
|
12
|
-
* The code in this file is distributed in the hope that it will be useful,
|
|
13
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
|
|
15
|
-
* General Public License for more details.
|
|
16
|
-
*
|
|
17
|
-
* As additional permission under GNU AGPL version 3 section 7, you may
|
|
18
|
-
* distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
|
|
19
|
-
* AGPL normally required by section 4, provided you include this license
|
|
20
|
-
* notice and a URL through which recipients can access the Corresponding
|
|
21
|
-
* Source.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/* global require, exports, setTimeout, clearTimeout, Buffer */
|
|
25
|
-
|
|
26
|
-
const chrome = require("selenium-webdriver/chrome");
|
|
27
|
-
const { Builder, Capabilities } = require("selenium-webdriver");
|
|
28
|
-
|
|
29
|
-
exports.initialize = async () => { };
|
|
30
|
-
|
|
31
|
-
exports.getPageData = async options => {
|
|
32
|
-
let driver;
|
|
33
|
-
try {
|
|
34
|
-
const builder = new Builder();
|
|
35
|
-
if (options.webDriverExecutablePath) {
|
|
36
|
-
builder.setChromeService(new chrome.ServiceBuilder(options.webDriverExecutablePath));
|
|
37
|
-
}
|
|
38
|
-
builder.setChromeOptions(getBrowserOptions(options));
|
|
39
|
-
setBuilderCapabilities(builder, options);
|
|
40
|
-
driver = builder.forBrowser("chrome").build();
|
|
41
|
-
return await getPageData(driver, options);
|
|
42
|
-
} finally {
|
|
43
|
-
if (driver) {
|
|
44
|
-
driver.quit();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
exports.closeBrowser = () => { };
|
|
50
|
-
|
|
51
|
-
function setBuilderCapabilities(builder, options) {
|
|
52
|
-
if (options.browserIgnoreInsecureCerts !== undefined && options.browserIgnoreInsecureCerts) {
|
|
53
|
-
const capabilities = new Capabilities();
|
|
54
|
-
capabilities.setAcceptInsecureCerts(true);
|
|
55
|
-
builder.withCapabilities(capabilities);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function getBrowserOptions(options) {
|
|
60
|
-
const chromeOptions = new chrome.Options();
|
|
61
|
-
const optionHeadless = (options.browserHeadless === undefined || options.browserHeadless) && !options.browserDebug;
|
|
62
|
-
if (optionHeadless) {
|
|
63
|
-
chromeOptions.headless();
|
|
64
|
-
}
|
|
65
|
-
if (options.browserExecutablePath) {
|
|
66
|
-
chromeOptions.setChromeBinaryPath(options.browserExecutablePath);
|
|
67
|
-
}
|
|
68
|
-
if (options.browserArgs) {
|
|
69
|
-
const args = JSON.parse(options.browserArgs);
|
|
70
|
-
args.forEach(argument => chromeOptions.addArguments(argument));
|
|
71
|
-
}
|
|
72
|
-
if (options.browserDisableWebSecurity === undefined || options.browserDisableWebSecurity) {
|
|
73
|
-
chromeOptions.addArguments("--disable-web-security");
|
|
74
|
-
}
|
|
75
|
-
chromeOptions.addArguments("--no-pings");
|
|
76
|
-
if (!optionHeadless) {
|
|
77
|
-
if (options.browserDebug) {
|
|
78
|
-
chromeOptions.addArguments("--auto-open-devtools-for-tabs");
|
|
79
|
-
}
|
|
80
|
-
const extensions = [];
|
|
81
|
-
if (options.browserBypassCSP === undefined || options.browserBypassCSP) {
|
|
82
|
-
extensions.push(encode(require.resolve("./extensions/signed/bypass_csp-0.0.3-an+fx.xpi")));
|
|
83
|
-
}
|
|
84
|
-
if (options.browserWaitUntil === undefined || options.browserWaitUntil == "networkidle0" || options.browserWaitUntil == "networkidle2") {
|
|
85
|
-
extensions.push(encode(require.resolve("./extensions/signed/network_idle-0.0.2-an+fx.xpi")));
|
|
86
|
-
}
|
|
87
|
-
chromeOptions.addExtensions(extensions);
|
|
88
|
-
}
|
|
89
|
-
if (options.userAgent) {
|
|
90
|
-
chromeOptions.addArguments("--user-agent=" + JSON.stringify(options.userAgent));
|
|
91
|
-
}
|
|
92
|
-
if (options.browserMobileEmulation) {
|
|
93
|
-
chromeOptions.setMobileEmulation({
|
|
94
|
-
deviceName: options.browserMobileEmulation
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
return chromeOptions;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async function getPageData(driver, options) {
|
|
101
|
-
const optionHeadless = (options.browserHeadless === undefined || options.browserHeadless) && !options.browserDebug;
|
|
102
|
-
driver.manage().setTimeouts({ script: options.browserLoadMaxTime, pageLoad: options.browserLoadMaxTime, implicit: options.browserLoadMaxTime });
|
|
103
|
-
if (options.browserWidth && options.browserHeight) {
|
|
104
|
-
const window = driver.manage().window();
|
|
105
|
-
if (window.setRect) {
|
|
106
|
-
window.setRect(options.browserHeight, options.browserWidth);
|
|
107
|
-
} else if (window.setSize) {
|
|
108
|
-
window.setSize(options.browserWidth, options.browserHeight);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const scripts = await require("./common/scripts.js").get(options);
|
|
112
|
-
if (options.browserDebug) {
|
|
113
|
-
// await driver.sleep(3000);
|
|
114
|
-
}
|
|
115
|
-
await driver.get(options.url);
|
|
116
|
-
if (options.browserCookies) {
|
|
117
|
-
await Promise.all(options.browserCookies.map(cookie => {
|
|
118
|
-
if (cookie.expires) {
|
|
119
|
-
cookie.expiry = cookie.expires;
|
|
120
|
-
delete cookie.expires;
|
|
121
|
-
}
|
|
122
|
-
return driver.manage().addCookie(cookie);
|
|
123
|
-
}));
|
|
124
|
-
await driver.get(options.url);
|
|
125
|
-
}
|
|
126
|
-
await driver.executeScript(scripts);
|
|
127
|
-
if (options.browserWaitUntil != "domcontentloaded") {
|
|
128
|
-
let scriptPromise;
|
|
129
|
-
if (!optionHeadless && (options.browserWaitUntil === undefined || options.browserWaitUntil == "networkidle0")) {
|
|
130
|
-
scriptPromise = driver.executeAsyncScript("addEventListener(\"single-file-network-idle-0\", () => arguments[0](), true)");
|
|
131
|
-
} else if (!optionHeadless && options.browserWaitUntil == "networkidle2") {
|
|
132
|
-
scriptPromise = driver.executeAsyncScript("addEventListener(\"single-file-network-idle-2\", () => arguments[0](), true)");
|
|
133
|
-
} else if (optionHeadless || options.browserWaitUntil == "load") {
|
|
134
|
-
scriptPromise = driver.executeAsyncScript("if (document.readyState == \"loading\" || document.readyState == \"interactive\") { addEventListener(\"load\", () => arguments[0]()) } else { arguments[0](); }");
|
|
135
|
-
}
|
|
136
|
-
let cancelTimeout;
|
|
137
|
-
const timeoutPromise = new Promise(resolve => {
|
|
138
|
-
const timeoutId = setTimeout(resolve, Math.max(0, options.browserLoadMaxTime - 5000));
|
|
139
|
-
cancelTimeout = () => {
|
|
140
|
-
clearTimeout(timeoutId);
|
|
141
|
-
resolve();
|
|
142
|
-
};
|
|
143
|
-
});
|
|
144
|
-
await Promise.race([scriptPromise, timeoutPromise]);
|
|
145
|
-
cancelTimeout();
|
|
146
|
-
}
|
|
147
|
-
if (options.browserWaitDelay) {
|
|
148
|
-
await driver.sleep(options.browserWaitDelay);
|
|
149
|
-
}
|
|
150
|
-
const result = await driver.executeAsyncScript(getPageDataScript(), options);
|
|
151
|
-
if (result.error) {
|
|
152
|
-
throw result.error;
|
|
153
|
-
} else {
|
|
154
|
-
return result.pageData;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function encode(file) {
|
|
159
|
-
return new Buffer.from(require("fs").readFileSync(file)).toString("base64");
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function getPageDataScript() {
|
|
163
|
-
return `
|
|
164
|
-
const [options, callback] = arguments;
|
|
165
|
-
getPageData()
|
|
166
|
-
.then(pageData => callback({ pageData }))
|
|
167
|
-
.catch(error => callback({ error: error && error.toString() }));
|
|
168
|
-
|
|
169
|
-
async function getPageData() {
|
|
170
|
-
return await singlefile.getPageData(options);
|
|
171
|
-
}
|
|
172
|
-
`;
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2010-2020 Gildas Lormeau
|
|
3
|
+
* contact : gildas.lormeau <at> gmail.com
|
|
4
|
+
*
|
|
5
|
+
* This file is part of SingleFile.
|
|
6
|
+
*
|
|
7
|
+
* The code in this file is free software: you can redistribute it and/or
|
|
8
|
+
* modify it under the terms of the GNU Affero General Public License
|
|
9
|
+
* (GNU AGPL) as published by the Free Software Foundation, either version 3
|
|
10
|
+
* of the License, or (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* The code in this file is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
|
|
15
|
+
* General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* As additional permission under GNU AGPL version 3 section 7, you may
|
|
18
|
+
* distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
|
|
19
|
+
* AGPL normally required by section 4, provided you include this license
|
|
20
|
+
* notice and a URL through which recipients can access the Corresponding
|
|
21
|
+
* Source.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/* global require, exports, setTimeout, clearTimeout, Buffer */
|
|
25
|
+
|
|
26
|
+
const chrome = require("selenium-webdriver/chrome");
|
|
27
|
+
const { Builder, Capabilities } = require("selenium-webdriver");
|
|
28
|
+
|
|
29
|
+
exports.initialize = async () => { };
|
|
30
|
+
|
|
31
|
+
exports.getPageData = async options => {
|
|
32
|
+
let driver;
|
|
33
|
+
try {
|
|
34
|
+
const builder = new Builder();
|
|
35
|
+
if (options.webDriverExecutablePath) {
|
|
36
|
+
builder.setChromeService(new chrome.ServiceBuilder(options.webDriverExecutablePath));
|
|
37
|
+
}
|
|
38
|
+
builder.setChromeOptions(getBrowserOptions(options));
|
|
39
|
+
setBuilderCapabilities(builder, options);
|
|
40
|
+
driver = builder.forBrowser("chrome").build();
|
|
41
|
+
return await getPageData(driver, options);
|
|
42
|
+
} finally {
|
|
43
|
+
if (driver) {
|
|
44
|
+
driver.quit();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports.closeBrowser = () => { };
|
|
50
|
+
|
|
51
|
+
function setBuilderCapabilities(builder, options) {
|
|
52
|
+
if (options.browserIgnoreInsecureCerts !== undefined && options.browserIgnoreInsecureCerts) {
|
|
53
|
+
const capabilities = new Capabilities();
|
|
54
|
+
capabilities.setAcceptInsecureCerts(true);
|
|
55
|
+
builder.withCapabilities(capabilities);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function getBrowserOptions(options) {
|
|
60
|
+
const chromeOptions = new chrome.Options();
|
|
61
|
+
const optionHeadless = (options.browserHeadless === undefined || options.browserHeadless) && !options.browserDebug;
|
|
62
|
+
if (optionHeadless) {
|
|
63
|
+
chromeOptions.headless();
|
|
64
|
+
}
|
|
65
|
+
if (options.browserExecutablePath) {
|
|
66
|
+
chromeOptions.setChromeBinaryPath(options.browserExecutablePath);
|
|
67
|
+
}
|
|
68
|
+
if (options.browserArgs) {
|
|
69
|
+
const args = JSON.parse(options.browserArgs);
|
|
70
|
+
args.forEach(argument => chromeOptions.addArguments(argument));
|
|
71
|
+
}
|
|
72
|
+
if (options.browserDisableWebSecurity === undefined || options.browserDisableWebSecurity) {
|
|
73
|
+
chromeOptions.addArguments("--disable-web-security");
|
|
74
|
+
}
|
|
75
|
+
chromeOptions.addArguments("--no-pings");
|
|
76
|
+
if (!optionHeadless) {
|
|
77
|
+
if (options.browserDebug) {
|
|
78
|
+
chromeOptions.addArguments("--auto-open-devtools-for-tabs");
|
|
79
|
+
}
|
|
80
|
+
const extensions = [];
|
|
81
|
+
if (options.browserBypassCSP === undefined || options.browserBypassCSP) {
|
|
82
|
+
extensions.push(encode(require.resolve("./extensions/signed/bypass_csp-0.0.3-an+fx.xpi")));
|
|
83
|
+
}
|
|
84
|
+
if (options.browserWaitUntil === undefined || options.browserWaitUntil == "networkidle0" || options.browserWaitUntil == "networkidle2") {
|
|
85
|
+
extensions.push(encode(require.resolve("./extensions/signed/network_idle-0.0.2-an+fx.xpi")));
|
|
86
|
+
}
|
|
87
|
+
chromeOptions.addExtensions(extensions);
|
|
88
|
+
}
|
|
89
|
+
if (options.userAgent) {
|
|
90
|
+
chromeOptions.addArguments("--user-agent=" + JSON.stringify(options.userAgent));
|
|
91
|
+
}
|
|
92
|
+
if (options.browserMobileEmulation) {
|
|
93
|
+
chromeOptions.setMobileEmulation({
|
|
94
|
+
deviceName: options.browserMobileEmulation
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return chromeOptions;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function getPageData(driver, options) {
|
|
101
|
+
const optionHeadless = (options.browserHeadless === undefined || options.browserHeadless) && !options.browserDebug;
|
|
102
|
+
driver.manage().setTimeouts({ script: options.browserLoadMaxTime, pageLoad: options.browserLoadMaxTime, implicit: options.browserLoadMaxTime });
|
|
103
|
+
if (options.browserWidth && options.browserHeight) {
|
|
104
|
+
const window = driver.manage().window();
|
|
105
|
+
if (window.setRect) {
|
|
106
|
+
window.setRect(options.browserHeight, options.browserWidth);
|
|
107
|
+
} else if (window.setSize) {
|
|
108
|
+
window.setSize(options.browserWidth, options.browserHeight);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const scripts = await require("./common/scripts.js").get(options);
|
|
112
|
+
if (options.browserDebug) {
|
|
113
|
+
// await driver.sleep(3000);
|
|
114
|
+
}
|
|
115
|
+
await driver.get(options.url);
|
|
116
|
+
if (options.browserCookies) {
|
|
117
|
+
await Promise.all(options.browserCookies.map(cookie => {
|
|
118
|
+
if (cookie.expires) {
|
|
119
|
+
cookie.expiry = cookie.expires;
|
|
120
|
+
delete cookie.expires;
|
|
121
|
+
}
|
|
122
|
+
return driver.manage().addCookie(cookie);
|
|
123
|
+
}));
|
|
124
|
+
await driver.get(options.url);
|
|
125
|
+
}
|
|
126
|
+
await driver.executeScript(scripts);
|
|
127
|
+
if (options.browserWaitUntil != "domcontentloaded") {
|
|
128
|
+
let scriptPromise;
|
|
129
|
+
if (!optionHeadless && (options.browserWaitUntil === undefined || options.browserWaitUntil == "networkidle0")) {
|
|
130
|
+
scriptPromise = driver.executeAsyncScript("addEventListener(\"single-file-network-idle-0\", () => arguments[0](), true)");
|
|
131
|
+
} else if (!optionHeadless && options.browserWaitUntil == "networkidle2") {
|
|
132
|
+
scriptPromise = driver.executeAsyncScript("addEventListener(\"single-file-network-idle-2\", () => arguments[0](), true)");
|
|
133
|
+
} else if (optionHeadless || options.browserWaitUntil == "load") {
|
|
134
|
+
scriptPromise = driver.executeAsyncScript("if (document.readyState == \"loading\" || document.readyState == \"interactive\") { addEventListener(\"load\", () => arguments[0]()) } else { arguments[0](); }");
|
|
135
|
+
}
|
|
136
|
+
let cancelTimeout;
|
|
137
|
+
const timeoutPromise = new Promise(resolve => {
|
|
138
|
+
const timeoutId = setTimeout(resolve, Math.max(0, options.browserLoadMaxTime - 5000));
|
|
139
|
+
cancelTimeout = () => {
|
|
140
|
+
clearTimeout(timeoutId);
|
|
141
|
+
resolve();
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
await Promise.race([scriptPromise, timeoutPromise]);
|
|
145
|
+
cancelTimeout();
|
|
146
|
+
}
|
|
147
|
+
if (options.browserWaitDelay) {
|
|
148
|
+
await driver.sleep(options.browserWaitDelay);
|
|
149
|
+
}
|
|
150
|
+
const result = await driver.executeAsyncScript(getPageDataScript(), options);
|
|
151
|
+
if (result.error) {
|
|
152
|
+
throw result.error;
|
|
153
|
+
} else {
|
|
154
|
+
return result.pageData;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function encode(file) {
|
|
159
|
+
return new Buffer.from(require("fs").readFileSync(file)).toString("base64");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function getPageDataScript() {
|
|
163
|
+
return `
|
|
164
|
+
const [options, callback] = arguments;
|
|
165
|
+
getPageData()
|
|
166
|
+
.then(pageData => callback({ pageData }))
|
|
167
|
+
.catch(error => callback({ error: error && error.toString() }));
|
|
168
|
+
|
|
169
|
+
async function getPageData() {
|
|
170
|
+
return await singlefile.getPageData(options);
|
|
171
|
+
}
|
|
172
|
+
`;
|
|
173
173
|
}
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).singlefileBootstrap={})}(this,(function(e){"use strict";const t="single-file-load-deferred-images-start",s="single-file-load-deferred-images-end",o="single-file-load-deferred-images-keep-zoom-level-start",n="single-file-load-deferred-images-keep-zoom-level-end",i="single-file-block-cookies-start",a="single-file-block-cookies-end",r="single-file-dispatch-scroll-event-start",l="single-file-dispatch-scroll-event-end",d="single-file-block-storage-start",c="single-file-block-storage-end",u="single-file-load-image",m="single-file-image-loaded",g=(e,t,s)=>globalThis.addEventListener(e,t,s),p=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},h=globalThis.CustomEvent,f=globalThis.document,T=globalThis.Document,E=globalThis.JSON;let b;b=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,f instanceof T&&(g("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,b.set(E.stringify(s),t)})),g("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,b.delete(E.stringify(s))})),g("single-file-clear-fonts",(()=>b=new Map)));const y="[\\x20\\t\\r\\n\\f]",I=new RegExp("\\\\([\\da-f]{1,6}"+y+"?|("+y+")|.)","ig");const w="single-file-on-before-capture",A="single-file-on-after-capture",v="single-file-request-get-adopted-stylesheets",S="single-file-unregister-request-get-adopted-stylesheets",N="single-file-response-get-adopted-stylesheets",R="data-single-file-removed-content",_="data-single-file-hidden-content",P="data-single-file-kept-content",C="data-single-file-hidden-frame",M="data-single-file-preserved-space-element",O="data-single-file-shadow-root-element",D="data-single-file-image",F="data-single-file-poster",L="data-single-file-video",x="data-single-file-canvas",U="data-single-file-movable-style",q="data-single-file-input-value",k="data-single-file-lazy-loaded-src",H="data-single-file-stylesheet",B="data-single-file-disabled-noscript",V="data-single-file-async-script",W="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",z=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD","BODY"],Y=/^'(.*?)'$/,j=/^"(.*?)"$/,G={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},K="single-file-ui-element",X="data:,",Z=(e,t,s)=>globalThis.addEventListener(e,t,s),J=globalThis.JSON;function $(e,t,s){e.querySelectorAll("noscript:not(["+B+"])").forEach((e=>{e.setAttribute(B,e.textContent),e.textContent=""})),function(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}(e),e.head&&e.head.querySelectorAll(W).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+W+", html > body > "+W);t.length&&(Array.from(e.childNodes).forEach((e=>e.remove())),t.forEach((t=>e.appendChild(t))))}));const o=new Map;let n;return t&&e.documentElement?(e.querySelectorAll("button button, a a").forEach((t=>{const s=e.createElement("template");s.setAttribute("data-single-file-invalid-element",""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=Q(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=le(t,e);s&&ne(e,s)&&(e.setAttribute(U,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(b.values()),stylesheets:ae(e),images:n.images,posters:n.posters,videos:n.videos,usedFonts:Array.from(n.usedFonts.values()),shadowRoots:n.shadowRoots,referrer:e.referrer,markedElements:n.markedElements,invalidElements:o,scrollPosition:{x:t.scrollX,y:t.scrollY},adoptedStyleSheets:ee(e.adoptedStyleSheets)}}function Q(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},i){if(s.childNodes){Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let a,r,l;if(!o.autoSaveExternalSave&&(o.removeHiddenElements||o.removeUnusedFonts||o.compressHTML)&&(l=le(e,s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(r=(i||s.closest("html > head"))&&z.includes(s.tagName.toUpperCase())||s.closest("details"),r||(a=i||ne(s,l),a&&(s.setAttribute(_,""),n.markedElements.push(s)))),!a)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(M,""),n.markedElements.push(s))}o.removeUnusedFonts&&(te(l,o,n.usedFonts),te(le(e,s,":first-letter"),o,n.usedFonts),te(le(e,s,":before"),o,n.usedFonts),te(le(e,s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,i,a){const r=s.tagName&&s.tagName.toUpperCase();if("CANVAS"==r)try{n.canvases.push({dataURI:s.toDataURL("image/png",""),backgroundColor:a.getPropertyValue("background-color")}),s.setAttribute(x,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==r){const t={currentSrc:i?X:o.loadDeferredImages&&s.getAttribute(k)||s.currentSrc};if(n.images.push(t),s.setAttribute(D,n.images.length-1),n.markedElements.push(s),s.removeAttribute(k),a=a||le(e,s)){t.size=function(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){const i=null==t.getAttribute("style");if(s=s||le(e,t)){let e,a,r,l,d,c,u,m,g=!1;if("content-box"==s.getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),s=t.style.getPropertyPriority("box-sizing"),o=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),g=t.clientWidth!=o,e?t.style.setProperty("box-sizing",e,s):t.style.removeProperty("box-sizing")}e=re("padding-left",s),a=re("padding-right",s),r=re("padding-top",s),l=re("padding-bottom",s),g?(d=re("border-left-width",s),c=re("border-right-width",s),u=re("border-top-width",s),m=re("border-bottom-width",s)):d=c=u=m=0,o=Math.max(0,t.clientWidth-e-a-d-c),n=Math.max(0,t.clientHeight-r-l-u-m),i&&t.removeAttribute("style")}}return{pxWidth:o,pxHeight:n}}(e,s,a);const o=a.getPropertyValue("box-shadow"),n=a.getPropertyValue("background-image");o&&"none"!=o||n&&"none"!=n||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=a.getPropertyValue("background-color"),t.objectFit=a.getPropertyValue("object-fit"),t.boxSizing=a.getPropertyValue("box-sizing"),t.objectPosition=a.getPropertyValue("object-position"))}}if("VIDEO"==r){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=le(e,s.parentNode);n.videos.push({positionParent:t&&t.getPropertyValue("position"),src:o,size:{pxWidth:s.clientWidth,pxHeight:s.clientHeight},currentTime:s.currentTime}),s.setAttribute(L,n.videos.length-1)}if(!s.getAttribute("poster")){const e=t.createElement("canvas"),o=e.getContext("2d");e.width=s.clientWidth,e.height=s.clientHeight;try{o.drawImage(s,0,0,e.width,e.height),n.posters.push(e.toDataURL("image/png","")),s.setAttribute(F,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==r&&i&&o.removeHiddenElements&&(s.setAttribute(C,""),n.markedElements.push(s));"INPUT"==r&&("password"!=s.type&&(s.setAttribute(q,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(q,s.checked),n.markedElements.push(s)));"TEXTAREA"==r&&(s.setAttribute(q,s.value),n.markedElements.push(s));"SELECT"==r&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(q,""),n.markedElements.push(e))}));"SCRIPT"==r&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(V,""),n.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,o,n,a,l);const d=!(s instanceof e.SVGElement)&&se(s);if(d&&!s.classList.contains(K)){const i={};s.setAttribute(O,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(i);try{if(d.adoptedStyleSheets)if(d.adoptedStyleSheets.length)i.adoptedStyleSheets=ee(d.adoptedStyleSheets);else if(void 0===d.adoptedStyleSheets.length){const e=e=>i.adoptedStyleSheets=e.detail.adoptedStyleSheets;s.addEventListener(N,e),s.dispatchEvent(new CustomEvent(v,{bubbles:!0})),s.removeEventListener(N,e)}}catch(e){}Q(e,t,d,o,n,a),i.content=d.innerHTML,i.mode=d.mode;try{d.adoptedStyleSheets&&void 0===d.adoptedStyleSheets.length&&s.dispatchEvent(new CustomEvent(S,{bubbles:!0}))}catch(e){}}Q(e,t,s,o,n,a),!o.autoSaveExternalSave&&o.removeHiddenElements&&i&&(r||""==s.getAttribute(P)?s.parentElement&&(s.parentElement.setAttribute(P,""),n.markedElements.push(s.parentElement)):a&&(s.setAttribute(R,""),n.markedElements.push(s)))}))}return n}function ee(e){return Array.from(e).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n")))}function te(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=oe(n),!t.loadedFonts||t.loadedFonts.find((e=>oe(e.family)==n&&e.style==o))){const t=(i=e.getPropertyValue("font-weight"),G[i.toLowerCase().trim()]||i),a=e.getPropertyValue("font-variant")||"normal",r=[n,t,o,a];s.set(J.stringify(r),[n,t,o,a])}var i}))}}function se(e){const t=globalThis.chrome;if(e.openOrClosedShadowRoot)return e.openOrClosedShadowRoot;if(!(t&&t.dom&&t.dom.openOrClosedShadowRoot))return e.shadowRoot;try{return t.dom.openOrClosedShadowRoot(e)}catch(t){return e.shadowRoot}}function oe(e=""){return function(e){e=e.match(Y)?e.replace(Y,"$1"):e.replace(j,"$1");return e.trim()}((t=e.trim(),t.replace(I,((e,t,s)=>{const o="0x"+t-65536;return o!=o||s?t:o<0?String.fromCharCode(o+65536):String.fromCharCode(o>>10|55296,1023&o|56320)})))).toLowerCase();var t}function ne(e,t){let s=!1;if(t){const o=t.getPropertyValue("display"),n=t.getPropertyValue("opacity"),i=t.getPropertyValue("visibility");if(s="none"==o,!s&&("0"==n||"hidden"==i)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();s=!t.width&&!t.height}}return Boolean(s)}function ie(e,t,s){if(e.querySelectorAll("["+B+"]").forEach((e=>{e.textContent=e.getAttribute(B),e.removeAttribute(B)})),e.querySelectorAll("meta[disabled-http-equiv]").forEach((e=>{e.setAttribute("http-equiv",e.getAttribute("disabled-http-equiv")),e.removeAttribute("disabled-http-equiv")})),e.head&&e.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach((e=>e.removeAttribute("hidden"))),!t){const s=[R,C,_,M,D,F,L,x,q,O,H,V];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(R),e.removeAttribute(_),e.removeAttribute(P),e.removeAttribute(C),e.removeAttribute(M),e.removeAttribute(D),e.removeAttribute(F),e.removeAttribute(L),e.removeAttribute(x),e.removeAttribute(q),e.removeAttribute(O),e.removeAttribute(H),e.removeAttribute(V),e.removeAttribute(U)})),s&&s.forEach(((e,t)=>e.replaceWith(t)))}function ae(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((s,o)=>{try{const n=e.createElement("style");n.textContent=s.textContent,e.body.appendChild(n);const i=n.sheet;n.remove(),i&&i.cssRules.length==s.sheet.cssRules.length||(s.setAttribute(H,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function re(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function le(e,t,s){try{return e.getComputedStyle(t,s)}catch(e){}}const de={LAZY_SRC_ATTRIBUTE_NAME:k,SINGLE_FILE_UI_ELEMENT_CLASS:K},ce=10,ue="attributes",me=globalThis.browser,ge=globalThis.document,pe=globalThis.MutationObserver,he=(e,t,s)=>globalThis.addEventListener(e,t,s),fe=(e,t,s)=>globalThis.removeEventListener(e,t,s),Te=new Map;let Ee;async function be(e){if(ge.documentElement){Te.clear();const s=ge.body&&ge.body.scrollHeight||ge.documentElement.scrollHeight,n=ge.body&&ge.body.scrollWidth||ge.documentElement.scrollWidth;if(s>globalThis.innerHeight||n>globalThis.innerWidth){const a=Math.max(s-1.5*globalThis.innerHeight,0),l=Math.max(n-1.5*globalThis.innerWidth,0);if(globalThis.scrollY<a||globalThis.scrollX<l)return function(e){return Ee=0,new Promise((async s=>{let n;const a=new Set,l=new pe((async t=>{if((t=t.filter((e=>e.type==ue))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(de.LAZY_SRC_ATTRIBUTE_NAME,e.target.src),e.target.addEventListener("load",g)),"src"==e.attributeName||"srcset"==e.attributeName||e.target.tagName&&"SOURCE"==e.target.tagName.toUpperCase())return!e.target.classList||!e.target.classList.contains(de.SINGLE_FILE_UI_ELEMENT_CLASS)})).length&&(n=!0,await Ie(l,e,E),a.size||await ye(l,e,E))}}));async function c(t){await Ae("idleTimeout",(async()=>{n?Ee<ce&&(Ee++,Se("idleTimeout"),await c(Math.max(500,t/2))):(Se("loadTimeout"),Se("maxTimeout"),we(l,e,E))}),t,e.loadDeferredImagesNativeTimeout)}function g(e){const t=e.target;t.removeAttribute(de.LAZY_SRC_ATTRIBUTE_NAME),t.removeEventListener("load",g)}async function f(t){n=!0,await Ie(l,e,E),await ye(l,e,E),t.detail&&a.add(t.detail)}async function T(t){await Ie(l,e,E),await ye(l,e,E),a.delete(t.detail),a.size||await ye(l,e,E)}function E(e){l.disconnect(),fe(u,f),fe(m,T),s(e)}await c(2*e.loadDeferredImagesMaxIdleTime),await Ie(l,e,E),l.observe(ge,{subtree:!0,childList:!0,attributes:!0}),he(u,f),he(m,T),function(e){e.loadDeferredImagesBlockCookies&&p(new h(i)),e.loadDeferredImagesBlockStorage&&p(new h(d)),e.loadDeferredImagesDispatchScrollEvent&&p(new h(r)),e.loadDeferredImagesKeepZoomLevel?p(new h(o)):p(new h(t))}(e)}))}(e)}}}async function ye(e,t,s){await Ae("loadTimeout",(()=>we(e,t,s)),t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function Ie(e,t,s){await Ae("maxTimeout",(async()=>{await Se("loadTimeout"),await we(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function we(e,t,o){await Se("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&p(new h(a)),e.loadDeferredImagesBlockStorage&&p(new h(c)),e.loadDeferredImagesDispatchScrollEvent&&p(new h(l)),e.loadDeferredImagesKeepZoomLevel?p(new h(n)):p(new h(s))}(t),await Ae("endTimeout",(async()=>{await Se("maxTimeout"),o()}),t.loadDeferredImagesMaxIdleTime/2,t.loadDeferredImagesNativeTimeout),e.disconnect()}async function Ae(e,t,s,o){if(me&&me.runtime&&me.runtime.sendMessage&&!o){if(!Te.get(e)||!Te.get(e).pending){const o={callback:t,pending:!0};Te.set(e,o);try{await me.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){ve(e,t,s)}o.pending=!1}}else ve(e,t,s)}function ve(e,t,s){const o=Te.get(e);o&&globalThis.clearTimeout(o),Te.set(e,t),globalThis.setTimeout(t,s)}async function Se(e){if(me&&me.runtime&&me.runtime.sendMessage)try{await me.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){Ne(e)}else Ne(e)}function Ne(e){const t=Te.get(e);Te.delete(e),t&&globalThis.clearTimeout(t)}me&&me.runtime&&me.runtime.onMessage&&me.runtime.onMessage.addListener&&me.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=Te.get(e.type);if(t){Te.delete(e.type);try{t.callback()}catch(t){Ne(e.type)}}}}));const Re={ON_BEFORE_CAPTURE_EVENT_NAME:w,ON_AFTER_CAPTURE_EVENT_NAME:A,WIN_ID_ATTRIBUTE_NAME:"data-single-file-win-id",preProcessDoc:$,serialize:function(e){const t=e.doctype;let s="";return t&&(s="<!DOCTYPE "+t.nodeName,t.publicId?(s+=' PUBLIC "'+t.publicId+'"',t.systemId&&(s+=' "'+t.systemId+'"')):t.systemId&&(s+=' SYSTEM "'+t.systemId+'"'),t.internalSubset&&(s+=" ["+t.internalSubset+"]"),s+="> "),s+e.documentElement.outerHTML},postProcessDoc:ie,getShadowRoot:se},_e="__frameTree__::",Pe='iframe, frame, object[type="text/html"][data]',Ce="*",Me="singlefile.frameTree.initRequest",Oe="singlefile.frameTree.ackInitRequest",De="singlefile.frameTree.cleanupRequest",Fe="singlefile.frameTree.initResponse",Le="*",xe=5e3,Ue=".",qe=globalThis.window==globalThis.top,ke=globalThis.browser,He=globalThis.top,Be=globalThis.MessageChannel,Ve=globalThis.document,We=globalThis.JSON;let ze,Ye=globalThis.sessions;var je,Ge,Ke;function Xe(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function Ze(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,qe||(ze=globalThis.frameId=e.windowId),Qe(Ve,e.options,ze,t),qe||(e.options.userScriptEnabled&&s&&await s(Re.ON_BEFORE_CAPTURE_EVENT_NAME),ot({frames:[it(Ve,globalThis,ze,e.options,e.scrolling)],sessionId:t,requestedFrameId:Ve.documentElement.dataset.requestedFrameId&&ze}),e.options.userScriptEnabled&&s&&await s(Re.ON_AFTER_CAPTURE_EVENT_NAME),delete Ve.documentElement.dataset.requestedFrameId)}function Je(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;st(at(Ve),e.windowId,t)}}function $e(e){e.frames.forEach((t=>et("responseTimeouts",e.sessionId,t.windowId)));const t=Ye.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let s=t.frames.find((t=>e.windowId==t.windowId));s||(s={windowId:e.windowId},t.frames.push(s)),s.processed||(s.content=e.content,s.baseURI=e.baseURI,s.title=e.title,s.url=e.url,s.canvases=e.canvases,s.fonts=e.fonts,s.stylesheets=e.stylesheets,s.images=e.images,s.posters=e.posters,s.videos=e.videos,s.usedFonts=e.usedFonts,s.shadowRoots=e.shadowRoots,s.processed=e.processed,s.scrollPosition=e.scrollPosition,s.scrolling=e.scrolling,s.adoptedStyleSheets=e.adoptedStyleSheets)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(Ue).length-e.windowId.split(Ue).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function Qe(e,t,s,o){const n=at(e);!function(e,t,s,o,n){const i=[];let a;Ye.get(n)?a=Ye.get(n).requestTimeouts:(a={},Ye.set(n,{requestTimeouts:a}));t.forEach(((e,t)=>{const s=o+Ue+t;e.setAttribute(Re.WIN_ID_ATTRIBUTE_NAME,s),i.push({windowId:s})})),ot({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const i=o+Ue+t;try{nt(e.contentWindow,{method:Me,windowId:i,sessionId:n,options:s,scrolling:e.scrolling})}catch(e){}a[i]=globalThis.setTimeout((()=>ot({frames:[{windowId:i,processed:!0}],sessionId:n})),xe)})),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o),n.length&&function(e,t,s,o,n){const i=[];t.forEach(((e,t)=>{const a=o+Ue+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),et("requestTimeouts",n,a),Qe(r,s,a,n),i.push(it(r,t,a,s,e.scrolling))}catch(e){i.push({windowId:a,processed:!0})}})),ot({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function et(e,t,s){const o=Ye.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function tt(e,t){const s=Ye.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>ot({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function st(e,t,s){e.forEach(((e,o)=>{const n=t+Ue+o;e.removeAttribute(Re.WIN_ID_ATTRIBUTE_NAME);try{nt(e.contentWindow,{method:De,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+Ue+o;let i;try{i=e.contentDocument}catch(e){}if(i)try{st(at(i),n,s)}catch(e){}}))}function ot(e){e.method=Fe;try{He.singlefile.processors.frameTree.initResponse(e)}catch(t){nt(He,e,!0)}}function nt(e,t,s){if(e==He&&ke&&ke.runtime&&ke.runtime.sendMessage)ke.runtime.sendMessage(t);else if(s){const s=new Be;e.postMessage(_e+We.stringify({method:t.method,sessionId:t.sessionId}),Le,[s.port2]),s.port1.postMessage(t)}else e.postMessage(_e+We.stringify(t),Le)}function it(e,t,s,o,n){const i=Re.preProcessDoc(e,t,o),a=Re.serialize(e);Re.postProcessDoc(e,i.markedElements,i.invalidElements);return{windowId:s,content:a,baseURI:e.baseURI.split("#")[0],url:e.location.href,title:e.title,canvases:i.canvases,fonts:i.fonts,stylesheets:i.stylesheets,images:i.images,posters:i.posters,videos:i.videos,usedFonts:i.usedFonts,shadowRoots:i.shadowRoots,scrollPosition:i.scrollPosition,scrolling:n,adoptedStyleSheets:i.adoptedStyleSheets,processed:!0}}function at(e){let t=Array.from(e.querySelectorAll(Pe));return e.querySelectorAll(Ce).forEach((e=>{const s=Re.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(Pe)))})),t}Ye||(Ye=globalThis.sessions=new Map),qe&&(ze="0",ke&&ke.runtime&&ke.runtime.onMessage&&ke.runtime.onMessage.addListener&&ke.runtime.onMessage.addListener((e=>e.method==Fe?($e(e),Promise.resolve({})):e.method==Oe?(et("requestTimeouts",e.sessionId,e.windowId),tt(e.sessionId,e.windowId),Promise.resolve({})):void 0))),je="message",Ge=async e=>{if("string"==typeof e.data&&e.data.startsWith(_e)){e.preventDefault(),e.stopPropagation();const t=We.parse(e.data.substring(_e.length));t.method==Me?(e.source&&nt(e.source,{method:Oe,windowId:t.windowId,sessionId:t.sessionId}),qe||(globalThis.stop(),t.options.loadDeferredImages&&be(t.options),await Ze(t))):t.method==Oe?(et("requestTimeouts",t.sessionId,t.windowId),tt(t.sessionId,t.windowId)):t.method==De?Je(t):t.method==Fe&&Ye.get(t.sessionId)&&(e.ports[0].onmessage=e=>$e(e.data))}},Ke=!0,globalThis.addEventListener(je,Ge,Ke);var rt=Object.freeze({__proto__:null,getAsync:function(e){const t=Xe();return e=We.parse(We.stringify(e)),new Promise((s=>{Ye.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),Ze({windowId:ze,sessionId:t,options:e})}))},getSync:function(e){const t=Xe();e=We.parse(We.stringify(e)),Ye.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,qe||(ze=globalThis.frameId=e.windowId);Qe(Ve,e.options,ze,t),qe||(e.options.userScriptEnabled&&s&&s(Re.ON_BEFORE_CAPTURE_EVENT_NAME),ot({frames:[it(Ve,globalThis,ze,e.options,e.scrolling)],sessionId:t,requestedFrameId:Ve.documentElement.dataset.requestedFrameId&&ze}),e.options.userScriptEnabled&&s&&s(Re.ON_AFTER_CAPTURE_EVENT_NAME),delete Ve.documentElement.dataset.requestedFrameId)}({windowId:ze,sessionId:t,options:e});const s=Ye.get(t).frames;return s.sessionId=t,s},cleanup:function(e){Ye.delete(e),Je({windowId:ze,sessionId:e,options:{sessionId:e}})},initResponse:$e,TIMEOUT_INIT_REQUEST_MESSAGE:xe});const lt=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"],dt=1,ct=3,ut=8,mt=[{tagName:"HEAD",accept:e=>!e.childNodes.length||e.childNodes[0].nodeType==dt},{tagName:"BODY",accept:e=>!e.childNodes.length}],gt=[{tagName:"HTML",accept:e=>!e||e.nodeType!=ut},{tagName:"HEAD",accept:e=>!e||e.nodeType!=ut&&(e.nodeType!=ct||!ft(e.textContent))},{tagName:"BODY",accept:e=>!e||e.nodeType!=ut},{tagName:"LI",accept:(e,t)=>!e&&t.parentElement&&("UL"==Tt(t.parentElement)||"OL"==Tt(t.parentElement))||e&&["LI"].includes(Tt(e))},{tagName:"DT",accept:e=>!e||["DT","DD"].includes(Tt(e))},{tagName:"P",accept:e=>e&&["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DETAILS","DIV","DL","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","MAIN","NAV","OL","P","PRE","SECTION","TABLE","UL"].includes(Tt(e))},{tagName:"DD",accept:e=>!e||["DT","DD"].includes(Tt(e))},{tagName:"RT",accept:e=>!e||["RT","RP"].includes(Tt(e))},{tagName:"RP",accept:e=>!e||["RT","RP"].includes(Tt(e))},{tagName:"OPTGROUP",accept:e=>!e||["OPTGROUP"].includes(Tt(e))},{tagName:"OPTION",accept:e=>!e||["OPTION","OPTGROUP"].includes(Tt(e))},{tagName:"COLGROUP",accept:e=>!e||e.nodeType!=ut&&(e.nodeType!=ct||!ft(e.textContent))},{tagName:"CAPTION",accept:e=>!e||e.nodeType!=ut&&(e.nodeType!=ct||!ft(e.textContent))},{tagName:"THEAD",accept:e=>!e||["TBODY","TFOOT"].includes(Tt(e))},{tagName:"TBODY",accept:e=>!e||["TBODY","TFOOT"].includes(Tt(e))},{tagName:"TFOOT",accept:e=>!e},{tagName:"TR",accept:e=>!e||["TR"].includes(Tt(e))},{tagName:"TD",accept:e=>!e||["TD","TH"].includes(Tt(e))},{tagName:"TH",accept:e=>!e||["TD","TH"].includes(Tt(e))}],pt=["STYLE","SCRIPT","XMP","IFRAME","NOEMBED","NOFRAMES","PLAINTEXT","NOSCRIPT"];function ht(e,t,s){return e.nodeType==ct?function(e){const t=e.parentNode;let s;t&&t.nodeType==dt&&(s=Tt(t));return!s||pt.includes(s)?"SCRIPT"==s||"STYLE"==s?e.textContent.replace(/<\//gi,"<\\/").replace(/\/>/gi,"\\/>"):e.textContent:e.textContent.replace(/&/g,"&").replace(/\u00a0/g," ").replace(/</g,"<").replace(/>/g,">")}(e):e.nodeType==ut?"\x3c!--"+e.textContent+"--\x3e":e.nodeType==dt?function(e,t,s){const o=Tt(e),n=t&&mt.find((t=>o==Tt(t)&&t.accept(e)));let i="";n&&!e.attributes.length||(i="<"+o.toLowerCase(),Array.from(e.attributes).forEach((s=>i+=function(e,t,s){const o=e.name;let n="";if(!o.match(/["'>/=]/)){let i,a=e.value;s&&"class"==o&&(a=Array.from(t.classList).map((e=>e.trim())).join(" ")),a=a.replace(/&/g,"&").replace(/\u00a0/g," "),a.includes('"')&&(a.includes("'")||!s?a=a.replace(/"/g,"""):i=!0);const r=!s||a.match(/[ \t\n\f\r'"`=<>]/);n+=" ",e.namespace?"http://www.w3.org/XML/1998/namespace"==e.namespaceURI?n+="xml:"+o:"http://www.w3.org/2000/xmlns/"==e.namespaceURI?("xmlns"!==o&&(n+="xmlns:"),n+=o):"http://www.w3.org/1999/xlink"==e.namespaceURI?n+="xlink:"+o:n+=o:n+=o,""!=a&&(n+="=",r&&(n+=i?"'":'"'),n+=a,r&&(n+=i?"'":'"'))}return n}(s,e,t))),i+=">");"TEMPLATE"!=o||e.childNodes.length?Array.from(e.childNodes).forEach((e=>i+=ht(e,t,s||"svg"==o))):i+=e.innerHTML;const a=t&>.find((t=>o==Tt(t)&&t.accept(e.nextSibling,e)));(s||!a&&!lt.includes(o))&&(i+="</"+o.toLowerCase()+">");return i}(e,t,s):void 0}function ft(e){return Boolean(e.match(/^[ \t\n\f\r]/))}function Tt(e){return e.tagName&&e.tagName.toUpperCase()}const Et={frameTree:rt},bt={COMMENT_HEADER:"Page saved with SingleFile",COMMENT_HEADER_LEGACY:"Archive processed by SingleFile",ON_BEFORE_CAPTURE_EVENT_NAME:w,ON_AFTER_CAPTURE_EVENT_NAME:A,preProcessDoc:$,postProcessDoc:ie,serialize:(e,t)=>function(e,t){const s=e.doctype;let o="";return s&&(o="<!DOCTYPE "+s.nodeName,s.publicId?(o+=' PUBLIC "'+s.publicId+'"',s.systemId&&(o+=' "'+s.systemId+'"')):s.systemId&&(o+=' SYSTEM "'+s.systemId+'"'),s.internalSubset&&(o+=" ["+s.internalSubset+"]"),o+="> "),o+ht(e.documentElement,t)}(e,t),getShadowRoot:se};Z("single-file-user-script-init",(()=>globalThis._singleFile_waitForUserScript=async e=>{const t=new CustomEvent(e+"-request",{cancelable:!0}),s=new Promise((t=>Z(e+"-response",t)));(e=>{try{globalThis.dispatchEvent(e)}catch(e){}})(t),t.defaultPrevented&&await s})),e.helper=bt,e.processors=Et,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).singlefileBootstrap={})}(this,(function(e){"use strict";const t="single-file-load-deferred-images-start",s="single-file-load-deferred-images-end",o="single-file-load-deferred-images-keep-zoom-level-start",n="single-file-load-deferred-images-keep-zoom-level-end",i="single-file-block-cookies-start",a="single-file-block-cookies-end",r="single-file-dispatch-scroll-event-start",l="single-file-dispatch-scroll-event-end",d="single-file-block-storage-start",c="single-file-block-storage-end",u="single-file-load-image",m="single-file-image-loaded",g=(e,t,s)=>globalThis.addEventListener(e,t,s),p=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},h=globalThis.CustomEvent,f=globalThis.document,T=globalThis.Document,E=globalThis.JSON;let b;b=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,f instanceof T&&(g("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,b.set(E.stringify(s),t)})),g("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,b.delete(E.stringify(s))})),g("single-file-clear-fonts",(()=>b=new Map)));const y="[\\x20\\t\\r\\n\\f]",I=new RegExp("\\\\([\\da-f]{1,6}"+y+"?|("+y+")|.)","ig");const w="single-file-on-before-capture",A="single-file-on-after-capture",v="single-file-request-get-adopted-stylesheets",S="single-file-unregister-request-get-adopted-stylesheets",N="single-file-response-get-adopted-stylesheets",R="data-single-file-removed-content",_="data-single-file-hidden-content",P="data-single-file-kept-content",C="data-single-file-hidden-frame",M="data-single-file-preserved-space-element",O="data-single-file-shadow-root-element",D="data-single-file-image",F="data-single-file-poster",L="data-single-file-video",x="data-single-file-canvas",U="data-single-file-movable-style",q="data-single-file-input-value",k="data-single-file-lazy-loaded-src",H="data-single-file-stylesheet",B="data-single-file-disabled-noscript",V="data-single-file-async-script",W="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",z=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD","BODY"],Y=/^'(.*?)'$/,j=/^"(.*?)"$/,G={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},K="single-file-ui-element",X="data:,",Z=(e,t,s)=>globalThis.addEventListener(e,t,s),J=globalThis.JSON;function $(e,t,s){e.querySelectorAll("noscript:not(["+B+"])").forEach((e=>{e.setAttribute(B,e.textContent),e.textContent=""})),function(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}(e),e.head&&e.head.querySelectorAll(W).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+W+", html > body > "+W);t.length&&(Array.from(e.childNodes).forEach((e=>e.remove())),t.forEach((t=>e.appendChild(t))))}));const o=new Map;let n;return t&&e.documentElement?(e.querySelectorAll("button button, a a").forEach((t=>{const s=e.createElement("template");s.setAttribute("data-single-file-invalid-element",""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=Q(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=le(t,e);s&&ne(e,s)&&(e.setAttribute(U,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(b.values()),stylesheets:ae(e),images:n.images,posters:n.posters,videos:n.videos,usedFonts:Array.from(n.usedFonts.values()),shadowRoots:n.shadowRoots,referrer:e.referrer,markedElements:n.markedElements,invalidElements:o,scrollPosition:{x:t.scrollX,y:t.scrollY},adoptedStyleSheets:ee(e.adoptedStyleSheets)}}function Q(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},i){if(s.childNodes){Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let a,r,l;if(!o.autoSaveExternalSave&&(o.removeHiddenElements||o.removeUnusedFonts||o.compressHTML)&&(l=le(e,s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(r=(i||s.closest("html > head"))&&z.includes(s.tagName.toUpperCase())||s.closest("details"),r||(a=i||ne(s,l),a&&(s.setAttribute(_,""),n.markedElements.push(s)))),!a)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(M,""),n.markedElements.push(s))}o.removeUnusedFonts&&(te(l,o,n.usedFonts),te(le(e,s,":first-letter"),o,n.usedFonts),te(le(e,s,":before"),o,n.usedFonts),te(le(e,s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,i,a){const r=s.tagName&&s.tagName.toUpperCase();if("CANVAS"==r)try{n.canvases.push({dataURI:s.toDataURL("image/png",""),backgroundColor:a.getPropertyValue("background-color")}),s.setAttribute(x,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==r){const t={currentSrc:i?X:o.loadDeferredImages&&s.getAttribute(k)||s.currentSrc};if(n.images.push(t),s.setAttribute(D,n.images.length-1),n.markedElements.push(s),s.removeAttribute(k),a=a||le(e,s)){t.size=function(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){const i=null==t.getAttribute("style");if(s=s||le(e,t)){let e,a,r,l,d,c,u,m,g=!1;if("content-box"==s.getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),s=t.style.getPropertyPriority("box-sizing"),o=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),g=t.clientWidth!=o,e?t.style.setProperty("box-sizing",e,s):t.style.removeProperty("box-sizing")}e=re("padding-left",s),a=re("padding-right",s),r=re("padding-top",s),l=re("padding-bottom",s),g?(d=re("border-left-width",s),c=re("border-right-width",s),u=re("border-top-width",s),m=re("border-bottom-width",s)):d=c=u=m=0,o=Math.max(0,t.clientWidth-e-a-d-c),n=Math.max(0,t.clientHeight-r-l-u-m),i&&t.removeAttribute("style")}}return{pxWidth:o,pxHeight:n}}(e,s,a);const o=a.getPropertyValue("box-shadow"),n=a.getPropertyValue("background-image");o&&"none"!=o||n&&"none"!=n||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=a.getPropertyValue("background-color"),t.objectFit=a.getPropertyValue("object-fit"),t.boxSizing=a.getPropertyValue("box-sizing"),t.objectPosition=a.getPropertyValue("object-position"))}}if("VIDEO"==r){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=le(e,s.parentNode);n.videos.push({positionParent:t&&t.getPropertyValue("position"),src:o,size:{pxWidth:s.clientWidth,pxHeight:s.clientHeight},currentTime:s.currentTime}),s.setAttribute(L,n.videos.length-1)}if(!s.getAttribute("poster")){const e=t.createElement("canvas"),o=e.getContext("2d");e.width=s.clientWidth,e.height=s.clientHeight;try{o.drawImage(s,0,0,e.width,e.height),n.posters.push(e.toDataURL("image/png","")),s.setAttribute(F,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==r&&i&&o.removeHiddenElements&&(s.setAttribute(C,""),n.markedElements.push(s));"INPUT"==r&&("password"!=s.type&&(s.setAttribute(q,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(q,s.checked),n.markedElements.push(s)));"TEXTAREA"==r&&(s.setAttribute(q,s.value),n.markedElements.push(s));"SELECT"==r&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(q,""),n.markedElements.push(e))}));"SCRIPT"==r&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(V,""),n.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,o,n,a,l);const d=!(s instanceof e.SVGElement)&&se(s);if(d&&!s.classList.contains(K)){const i={};s.setAttribute(O,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(i);try{if(d.adoptedStyleSheets)if(d.adoptedStyleSheets.length)i.adoptedStyleSheets=ee(d.adoptedStyleSheets);else if(void 0===d.adoptedStyleSheets.length){const e=e=>i.adoptedStyleSheets=e.detail.adoptedStyleSheets;s.addEventListener(N,e),s.dispatchEvent(new CustomEvent(v,{bubbles:!0})),s.removeEventListener(N,e)}}catch(e){}Q(e,t,d,o,n,a),i.content=d.innerHTML,i.mode=d.mode;try{d.adoptedStyleSheets&&void 0===d.adoptedStyleSheets.length&&s.dispatchEvent(new CustomEvent(S,{bubbles:!0}))}catch(e){}}Q(e,t,s,o,n,a),!o.autoSaveExternalSave&&o.removeHiddenElements&&i&&(r||""==s.getAttribute(P)?s.parentElement&&(s.parentElement.setAttribute(P,""),n.markedElements.push(s.parentElement)):a&&(s.setAttribute(R,""),n.markedElements.push(s)))}))}return n}function ee(e){return e?Array.from(e).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))):[]}function te(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=oe(n),!t.loadedFonts||t.loadedFonts.find((e=>oe(e.family)==n&&e.style==o))){const t=(i=e.getPropertyValue("font-weight"),G[i.toLowerCase().trim()]||i),a=e.getPropertyValue("font-variant")||"normal",r=[n,t,o,a];s.set(J.stringify(r),[n,t,o,a])}var i}))}}function se(e){const t=globalThis.chrome;if(e.openOrClosedShadowRoot)return e.openOrClosedShadowRoot;if(!(t&&t.dom&&t.dom.openOrClosedShadowRoot))return e.shadowRoot;try{return t.dom.openOrClosedShadowRoot(e)}catch(t){return e.shadowRoot}}function oe(e=""){return function(e){e=e.match(Y)?e.replace(Y,"$1"):e.replace(j,"$1");return e.trim()}((t=e.trim(),t.replace(I,((e,t,s)=>{const o="0x"+t-65536;return o!=o||s?t:o<0?String.fromCharCode(o+65536):String.fromCharCode(o>>10|55296,1023&o|56320)})))).toLowerCase();var t}function ne(e,t){let s=!1;if(t){const o=t.getPropertyValue("display"),n=t.getPropertyValue("opacity"),i=t.getPropertyValue("visibility");if(s="none"==o,!s&&("0"==n||"hidden"==i)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();s=!t.width&&!t.height}}return Boolean(s)}function ie(e,t,s){if(e.querySelectorAll("["+B+"]").forEach((e=>{e.textContent=e.getAttribute(B),e.removeAttribute(B)})),e.querySelectorAll("meta[disabled-http-equiv]").forEach((e=>{e.setAttribute("http-equiv",e.getAttribute("disabled-http-equiv")),e.removeAttribute("disabled-http-equiv")})),e.head&&e.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach((e=>e.removeAttribute("hidden"))),!t){const s=[R,C,_,M,D,F,L,x,q,O,H,V];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(R),e.removeAttribute(_),e.removeAttribute(P),e.removeAttribute(C),e.removeAttribute(M),e.removeAttribute(D),e.removeAttribute(F),e.removeAttribute(L),e.removeAttribute(x),e.removeAttribute(q),e.removeAttribute(O),e.removeAttribute(H),e.removeAttribute(V),e.removeAttribute(U)})),s&&s.forEach(((e,t)=>e.replaceWith(t)))}function ae(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((s,o)=>{try{const n=e.createElement("style");n.textContent=s.textContent,e.body.appendChild(n);const i=n.sheet;n.remove(),i&&i.cssRules.length==s.sheet.cssRules.length||(s.setAttribute(H,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function re(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function le(e,t,s){try{return e.getComputedStyle(t,s)}catch(e){}}const de={LAZY_SRC_ATTRIBUTE_NAME:k,SINGLE_FILE_UI_ELEMENT_CLASS:K},ce=10,ue="attributes",me=globalThis.browser,ge=globalThis.document,pe=globalThis.MutationObserver,he=(e,t,s)=>globalThis.addEventListener(e,t,s),fe=(e,t,s)=>globalThis.removeEventListener(e,t,s),Te=new Map;let Ee;async function be(e){if(ge.documentElement){Te.clear();const s=ge.body&&ge.body.scrollHeight||ge.documentElement.scrollHeight,n=ge.body&&ge.body.scrollWidth||ge.documentElement.scrollWidth;if(s>globalThis.innerHeight||n>globalThis.innerWidth){const a=Math.max(s-1.5*globalThis.innerHeight,0),l=Math.max(n-1.5*globalThis.innerWidth,0);if(globalThis.scrollY<a||globalThis.scrollX<l)return function(e){return Ee=0,new Promise((async s=>{let n;const a=new Set,l=new pe((async t=>{if((t=t.filter((e=>e.type==ue))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(de.LAZY_SRC_ATTRIBUTE_NAME,e.target.src),e.target.addEventListener("load",g)),"src"==e.attributeName||"srcset"==e.attributeName||e.target.tagName&&"SOURCE"==e.target.tagName.toUpperCase())return!e.target.classList||!e.target.classList.contains(de.SINGLE_FILE_UI_ELEMENT_CLASS)})).length&&(n=!0,await Ie(l,e,E),a.size||await ye(l,e,E))}}));async function c(t){await Ae("idleTimeout",(async()=>{n?Ee<ce&&(Ee++,Se("idleTimeout"),await c(Math.max(500,t/2))):(Se("loadTimeout"),Se("maxTimeout"),we(l,e,E))}),t,e.loadDeferredImagesNativeTimeout)}function g(e){const t=e.target;t.removeAttribute(de.LAZY_SRC_ATTRIBUTE_NAME),t.removeEventListener("load",g)}async function f(t){n=!0,await Ie(l,e,E),await ye(l,e,E),t.detail&&a.add(t.detail)}async function T(t){await Ie(l,e,E),await ye(l,e,E),a.delete(t.detail),a.size||await ye(l,e,E)}function E(e){l.disconnect(),fe(u,f),fe(m,T),s(e)}await c(2*e.loadDeferredImagesMaxIdleTime),await Ie(l,e,E),l.observe(ge,{subtree:!0,childList:!0,attributes:!0}),he(u,f),he(m,T),function(e){e.loadDeferredImagesBlockCookies&&p(new h(i)),e.loadDeferredImagesBlockStorage&&p(new h(d)),e.loadDeferredImagesDispatchScrollEvent&&p(new h(r)),e.loadDeferredImagesKeepZoomLevel?p(new h(o)):p(new h(t))}(e)}))}(e)}}}async function ye(e,t,s){await Ae("loadTimeout",(()=>we(e,t,s)),t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function Ie(e,t,s){await Ae("maxTimeout",(async()=>{await Se("loadTimeout"),await we(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function we(e,t,o){await Se("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&p(new h(a)),e.loadDeferredImagesBlockStorage&&p(new h(c)),e.loadDeferredImagesDispatchScrollEvent&&p(new h(l)),e.loadDeferredImagesKeepZoomLevel?p(new h(n)):p(new h(s))}(t),await Ae("endTimeout",(async()=>{await Se("maxTimeout"),o()}),t.loadDeferredImagesMaxIdleTime/2,t.loadDeferredImagesNativeTimeout),e.disconnect()}async function Ae(e,t,s,o){if(me&&me.runtime&&me.runtime.sendMessage&&!o){if(!Te.get(e)||!Te.get(e).pending){const o={callback:t,pending:!0};Te.set(e,o);try{await me.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){ve(e,t,s)}o.pending=!1}}else ve(e,t,s)}function ve(e,t,s){const o=Te.get(e);o&&globalThis.clearTimeout(o),Te.set(e,t),globalThis.setTimeout(t,s)}async function Se(e){if(me&&me.runtime&&me.runtime.sendMessage)try{await me.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){Ne(e)}else Ne(e)}function Ne(e){const t=Te.get(e);Te.delete(e),t&&globalThis.clearTimeout(t)}me&&me.runtime&&me.runtime.onMessage&&me.runtime.onMessage.addListener&&me.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=Te.get(e.type);if(t){Te.delete(e.type);try{t.callback()}catch(t){Ne(e.type)}}}}));const Re={ON_BEFORE_CAPTURE_EVENT_NAME:w,ON_AFTER_CAPTURE_EVENT_NAME:A,WIN_ID_ATTRIBUTE_NAME:"data-single-file-win-id",preProcessDoc:$,serialize:function(e){const t=e.doctype;let s="";return t&&(s="<!DOCTYPE "+t.nodeName,t.publicId?(s+=' PUBLIC "'+t.publicId+'"',t.systemId&&(s+=' "'+t.systemId+'"')):t.systemId&&(s+=' SYSTEM "'+t.systemId+'"'),t.internalSubset&&(s+=" ["+t.internalSubset+"]"),s+="> "),s+e.documentElement.outerHTML},postProcessDoc:ie,getShadowRoot:se},_e="__frameTree__::",Pe='iframe, frame, object[type="text/html"][data]',Ce="*",Me="singlefile.frameTree.initRequest",Oe="singlefile.frameTree.ackInitRequest",De="singlefile.frameTree.cleanupRequest",Fe="singlefile.frameTree.initResponse",Le="*",xe=5e3,Ue=".",qe=globalThis.window==globalThis.top,ke=globalThis.browser,He=globalThis.top,Be=globalThis.MessageChannel,Ve=globalThis.document,We=globalThis.JSON;let ze,Ye=globalThis.sessions;var je,Ge,Ke;function Xe(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function Ze(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,qe||(ze=globalThis.frameId=e.windowId),Qe(Ve,e.options,ze,t),qe||(e.options.userScriptEnabled&&s&&await s(Re.ON_BEFORE_CAPTURE_EVENT_NAME),ot({frames:[it(Ve,globalThis,ze,e.options,e.scrolling)],sessionId:t,requestedFrameId:Ve.documentElement.dataset.requestedFrameId&&ze}),e.options.userScriptEnabled&&s&&await s(Re.ON_AFTER_CAPTURE_EVENT_NAME),delete Ve.documentElement.dataset.requestedFrameId)}function Je(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;st(at(Ve),e.windowId,t)}}function $e(e){e.frames.forEach((t=>et("responseTimeouts",e.sessionId,t.windowId)));const t=Ye.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let s=t.frames.find((t=>e.windowId==t.windowId));s||(s={windowId:e.windowId},t.frames.push(s)),s.processed||(s.content=e.content,s.baseURI=e.baseURI,s.title=e.title,s.url=e.url,s.canvases=e.canvases,s.fonts=e.fonts,s.stylesheets=e.stylesheets,s.images=e.images,s.posters=e.posters,s.videos=e.videos,s.usedFonts=e.usedFonts,s.shadowRoots=e.shadowRoots,s.processed=e.processed,s.scrollPosition=e.scrollPosition,s.scrolling=e.scrolling,s.adoptedStyleSheets=e.adoptedStyleSheets)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(Ue).length-e.windowId.split(Ue).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function Qe(e,t,s,o){const n=at(e);!function(e,t,s,o,n){const i=[];let a;Ye.get(n)?a=Ye.get(n).requestTimeouts:(a={},Ye.set(n,{requestTimeouts:a}));t.forEach(((e,t)=>{const s=o+Ue+t;e.setAttribute(Re.WIN_ID_ATTRIBUTE_NAME,s),i.push({windowId:s})})),ot({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const i=o+Ue+t;try{nt(e.contentWindow,{method:Me,windowId:i,sessionId:n,options:s,scrolling:e.scrolling})}catch(e){}a[i]=globalThis.setTimeout((()=>ot({frames:[{windowId:i,processed:!0}],sessionId:n})),xe)})),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o),n.length&&function(e,t,s,o,n){const i=[];t.forEach(((e,t)=>{const a=o+Ue+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),et("requestTimeouts",n,a),Qe(r,s,a,n),i.push(it(r,t,a,s,e.scrolling))}catch(e){i.push({windowId:a,processed:!0})}})),ot({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function et(e,t,s){const o=Ye.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function tt(e,t){const s=Ye.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>ot({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function st(e,t,s){e.forEach(((e,o)=>{const n=t+Ue+o;e.removeAttribute(Re.WIN_ID_ATTRIBUTE_NAME);try{nt(e.contentWindow,{method:De,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+Ue+o;let i;try{i=e.contentDocument}catch(e){}if(i)try{st(at(i),n,s)}catch(e){}}))}function ot(e){e.method=Fe;try{He.singlefile.processors.frameTree.initResponse(e)}catch(t){nt(He,e,!0)}}function nt(e,t,s){if(e==He&&ke&&ke.runtime&&ke.runtime.sendMessage)ke.runtime.sendMessage(t);else if(s){const s=new Be;e.postMessage(_e+We.stringify({method:t.method,sessionId:t.sessionId}),Le,[s.port2]),s.port1.postMessage(t)}else e.postMessage(_e+We.stringify(t),Le)}function it(e,t,s,o,n){const i=Re.preProcessDoc(e,t,o),a=Re.serialize(e);Re.postProcessDoc(e,i.markedElements,i.invalidElements);return{windowId:s,content:a,baseURI:e.baseURI.split("#")[0],url:e.location.href,title:e.title,canvases:i.canvases,fonts:i.fonts,stylesheets:i.stylesheets,images:i.images,posters:i.posters,videos:i.videos,usedFonts:i.usedFonts,shadowRoots:i.shadowRoots,scrollPosition:i.scrollPosition,scrolling:n,adoptedStyleSheets:i.adoptedStyleSheets,processed:!0}}function at(e){let t=Array.from(e.querySelectorAll(Pe));return e.querySelectorAll(Ce).forEach((e=>{const s=Re.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(Pe)))})),t}Ye||(Ye=globalThis.sessions=new Map),qe&&(ze="0",ke&&ke.runtime&&ke.runtime.onMessage&&ke.runtime.onMessage.addListener&&ke.runtime.onMessage.addListener((e=>e.method==Fe?($e(e),Promise.resolve({})):e.method==Oe?(et("requestTimeouts",e.sessionId,e.windowId),tt(e.sessionId,e.windowId),Promise.resolve({})):void 0))),je="message",Ge=async e=>{if("string"==typeof e.data&&e.data.startsWith(_e)){e.preventDefault(),e.stopPropagation();const t=We.parse(e.data.substring(_e.length));t.method==Me?(e.source&&nt(e.source,{method:Oe,windowId:t.windowId,sessionId:t.sessionId}),qe||(globalThis.stop(),t.options.loadDeferredImages&&be(t.options),await Ze(t))):t.method==Oe?(et("requestTimeouts",t.sessionId,t.windowId),tt(t.sessionId,t.windowId)):t.method==De?Je(t):t.method==Fe&&Ye.get(t.sessionId)&&(e.ports[0].onmessage=e=>$e(e.data))}},Ke=!0,globalThis.addEventListener(je,Ge,Ke);var rt=Object.freeze({__proto__:null,getAsync:function(e){const t=Xe();return e=We.parse(We.stringify(e)),new Promise((s=>{Ye.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),Ze({windowId:ze,sessionId:t,options:e})}))},getSync:function(e){const t=Xe();e=We.parse(We.stringify(e)),Ye.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,qe||(ze=globalThis.frameId=e.windowId);Qe(Ve,e.options,ze,t),qe||(e.options.userScriptEnabled&&s&&s(Re.ON_BEFORE_CAPTURE_EVENT_NAME),ot({frames:[it(Ve,globalThis,ze,e.options,e.scrolling)],sessionId:t,requestedFrameId:Ve.documentElement.dataset.requestedFrameId&&ze}),e.options.userScriptEnabled&&s&&s(Re.ON_AFTER_CAPTURE_EVENT_NAME),delete Ve.documentElement.dataset.requestedFrameId)}({windowId:ze,sessionId:t,options:e});const s=Ye.get(t).frames;return s.sessionId=t,s},cleanup:function(e){Ye.delete(e),Je({windowId:ze,sessionId:e,options:{sessionId:e}})},initResponse:$e,TIMEOUT_INIT_REQUEST_MESSAGE:xe});const lt=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"],dt=1,ct=3,ut=8,mt=[{tagName:"HEAD",accept:e=>!e.childNodes.length||e.childNodes[0].nodeType==dt},{tagName:"BODY",accept:e=>!e.childNodes.length}],gt=[{tagName:"HTML",accept:e=>!e||e.nodeType!=ut},{tagName:"HEAD",accept:e=>!e||e.nodeType!=ut&&(e.nodeType!=ct||!ft(e.textContent))},{tagName:"BODY",accept:e=>!e||e.nodeType!=ut},{tagName:"LI",accept:(e,t)=>!e&&t.parentElement&&("UL"==Tt(t.parentElement)||"OL"==Tt(t.parentElement))||e&&["LI"].includes(Tt(e))},{tagName:"DT",accept:e=>!e||["DT","DD"].includes(Tt(e))},{tagName:"P",accept:e=>e&&["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DETAILS","DIV","DL","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","MAIN","NAV","OL","P","PRE","SECTION","TABLE","UL"].includes(Tt(e))},{tagName:"DD",accept:e=>!e||["DT","DD"].includes(Tt(e))},{tagName:"RT",accept:e=>!e||["RT","RP"].includes(Tt(e))},{tagName:"RP",accept:e=>!e||["RT","RP"].includes(Tt(e))},{tagName:"OPTGROUP",accept:e=>!e||["OPTGROUP"].includes(Tt(e))},{tagName:"OPTION",accept:e=>!e||["OPTION","OPTGROUP"].includes(Tt(e))},{tagName:"COLGROUP",accept:e=>!e||e.nodeType!=ut&&(e.nodeType!=ct||!ft(e.textContent))},{tagName:"CAPTION",accept:e=>!e||e.nodeType!=ut&&(e.nodeType!=ct||!ft(e.textContent))},{tagName:"THEAD",accept:e=>!e||["TBODY","TFOOT"].includes(Tt(e))},{tagName:"TBODY",accept:e=>!e||["TBODY","TFOOT"].includes(Tt(e))},{tagName:"TFOOT",accept:e=>!e},{tagName:"TR",accept:e=>!e||["TR"].includes(Tt(e))},{tagName:"TD",accept:e=>!e||["TD","TH"].includes(Tt(e))},{tagName:"TH",accept:e=>!e||["TD","TH"].includes(Tt(e))}],pt=["STYLE","SCRIPT","XMP","IFRAME","NOEMBED","NOFRAMES","PLAINTEXT","NOSCRIPT"];function ht(e,t,s){return e.nodeType==ct?function(e){const t=e.parentNode;let s;t&&t.nodeType==dt&&(s=Tt(t));return!s||pt.includes(s)?"SCRIPT"==s||"STYLE"==s?e.textContent.replace(/<\//gi,"<\\/").replace(/\/>/gi,"\\/>"):e.textContent:e.textContent.replace(/&/g,"&").replace(/\u00a0/g," ").replace(/</g,"<").replace(/>/g,">")}(e):e.nodeType==ut?"\x3c!--"+e.textContent+"--\x3e":e.nodeType==dt?function(e,t,s){const o=Tt(e),n=t&&mt.find((t=>o==Tt(t)&&t.accept(e)));let i="";n&&!e.attributes.length||(i="<"+o.toLowerCase(),Array.from(e.attributes).forEach((s=>i+=function(e,t,s){const o=e.name;let n="";if(!o.match(/["'>/=]/)){let i,a=e.value;s&&"class"==o&&(a=Array.from(t.classList).map((e=>e.trim())).join(" ")),a=a.replace(/&/g,"&").replace(/\u00a0/g," "),a.includes('"')&&(a.includes("'")||!s?a=a.replace(/"/g,"""):i=!0);const r=!s||a.match(/[ \t\n\f\r'"`=<>]/);n+=" ",e.namespace?"http://www.w3.org/XML/1998/namespace"==e.namespaceURI?n+="xml:"+o:"http://www.w3.org/2000/xmlns/"==e.namespaceURI?("xmlns"!==o&&(n+="xmlns:"),n+=o):"http://www.w3.org/1999/xlink"==e.namespaceURI?n+="xlink:"+o:n+=o:n+=o,""!=a&&(n+="=",r&&(n+=i?"'":'"'),n+=a,r&&(n+=i?"'":'"'))}return n}(s,e,t))),i+=">");"TEMPLATE"!=o||e.childNodes.length?Array.from(e.childNodes).forEach((e=>i+=ht(e,t,s||"svg"==o))):i+=e.innerHTML;const a=t&>.find((t=>o==Tt(t)&&t.accept(e.nextSibling,e)));(s||!a&&!lt.includes(o))&&(i+="</"+o.toLowerCase()+">");return i}(e,t,s):void 0}function ft(e){return Boolean(e.match(/^[ \t\n\f\r]/))}function Tt(e){return e.tagName&&e.tagName.toUpperCase()}const Et={frameTree:rt},bt={COMMENT_HEADER:"Page saved with SingleFile",COMMENT_HEADER_LEGACY:"Archive processed by SingleFile",ON_BEFORE_CAPTURE_EVENT_NAME:w,ON_AFTER_CAPTURE_EVENT_NAME:A,preProcessDoc:$,postProcessDoc:ie,serialize:(e,t)=>function(e,t){const s=e.doctype;let o="";return s&&(o="<!DOCTYPE "+s.nodeName,s.publicId?(o+=' PUBLIC "'+s.publicId+'"',s.systemId&&(o+=' "'+s.systemId+'"')):s.systemId&&(o+=' SYSTEM "'+s.systemId+'"'),s.internalSubset&&(o+=" ["+s.internalSubset+"]"),o+="> "),o+ht(e.documentElement,t)}(e,t),getShadowRoot:se};Z("single-file-user-script-init",(()=>globalThis._singleFile_waitForUserScript=async e=>{const t=new CustomEvent(e+"-request",{cancelable:!0}),s=new Promise((t=>Z(e+"-response",t)));(e=>{try{globalThis.dispatchEvent(e)}catch(e){}})(t),t.defaultPrevented&&await s})),e.helper=bt,e.processors=Et,Object.defineProperty(e,"__esModule",{value:!0})}));
|