Spaces:
Sleeping
Sleeping
and
commited on
Commit
•
96ef720
1
Parent(s):
ab2fb2f
index.mjs
CHANGED
@@ -66,13 +66,13 @@ async function text_from_url(url, cookie) {
|
|
66 |
return text;
|
67 |
}
|
68 |
|
69 |
-
async function screenshot(url, cookie) {
|
70 |
let { browser, context } = globalThis.state;
|
71 |
if (!browser) {
|
72 |
await locks.request('playwright_browser', async lock => {
|
73 |
browser = globalThis.state.browser = await chromium.launch();
|
74 |
context = globalThis.state.context = await browser.newContext({
|
75 |
-
javaScriptEnabled:
|
76 |
}/*devices['iPhone 11']*/);
|
77 |
});
|
78 |
}
|
@@ -122,7 +122,7 @@ const server = http.createServer(async function(req, res) {
|
|
122 |
|
123 |
res.end(text);
|
124 |
} else if (pathname == '/screenshot') {
|
125 |
-
let buffer = await screenshot(_url, cookie);
|
126 |
|
127 |
res.writeHead(200,{'Content-type':'image/png'});
|
128 |
res.end(buffer);
|
|
|
66 |
return text;
|
67 |
}
|
68 |
|
69 |
+
async function screenshot(url, cookie, js_enabled) {
|
70 |
let { browser, context } = globalThis.state;
|
71 |
if (!browser) {
|
72 |
await locks.request('playwright_browser', async lock => {
|
73 |
browser = globalThis.state.browser = await chromium.launch();
|
74 |
context = globalThis.state.context = await browser.newContext({
|
75 |
+
javaScriptEnabled: js_enabled
|
76 |
}/*devices['iPhone 11']*/);
|
77 |
});
|
78 |
}
|
|
|
122 |
|
123 |
res.end(text);
|
124 |
} else if (pathname == '/screenshot') {
|
125 |
+
let buffer = await screenshot(_url, cookie, true);
|
126 |
|
127 |
res.writeHead(200,{'Content-type':'image/png'});
|
128 |
res.end(buffer);
|