Update index.js
Browse files
index.js
CHANGED
|
@@ -35,6 +35,7 @@ app.all(
|
|
| 35 |
(_, res) => res.json({ msg: 'Hello World' })
|
| 36 |
)
|
| 37 |
|
|
|
|
| 38 |
app.get('/ss', async (req, res) => {
|
| 39 |
const {
|
| 40 |
delay = 0,
|
|
@@ -47,22 +48,13 @@ app.get('/ss', async (req, res) => {
|
|
| 47 |
return res.redirect('/')
|
| 48 |
|
| 49 |
const isGhost = /^ghost$/i.test(mode)
|
| 50 |
-
|
| 51 |
-
const label = format(
|
| 52 |
-
'[%s]', isGhost ?
|
| 53 |
-
'PuppeteerGhost' : 'PuppeteerRealBrowser'
|
| 54 |
-
)
|
| 55 |
-
console.time(label)
|
| 56 |
-
|
| 57 |
const ctx = isGhost ?
|
| 58 |
await pg.launch({
|
| 59 |
-
executablePath
|
| 60 |
headless: 'new'
|
| 61 |
}) :
|
| 62 |
await prb.connect({
|
| 63 |
-
customConfig: {
|
| 64 |
-
executablePath: env.CHROME_BIN
|
| 65 |
-
},
|
| 66 |
disableXvfb: true,
|
| 67 |
headless: 'new',
|
| 68 |
turnstile: true
|
|
@@ -101,10 +93,7 @@ app.get('/ss', async (req, res) => {
|
|
| 101 |
msg: format(e?.message || e)
|
| 102 |
})
|
| 103 |
} finally {
|
| 104 |
-
|
| 105 |
-
await (
|
| 106 |
-
isGhost ? ctx : ctx.browser
|
| 107 |
-
).close()
|
| 108 |
}
|
| 109 |
})
|
| 110 |
|
|
|
|
| 35 |
(_, res) => res.json({ msg: 'Hello World' })
|
| 36 |
)
|
| 37 |
|
| 38 |
+
const executablePath = env.CHROME_BIN
|
| 39 |
app.get('/ss', async (req, res) => {
|
| 40 |
const {
|
| 41 |
delay = 0,
|
|
|
|
| 48 |
return res.redirect('/')
|
| 49 |
|
| 50 |
const isGhost = /^ghost$/i.test(mode)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
const ctx = isGhost ?
|
| 52 |
await pg.launch({
|
| 53 |
+
executablePath,
|
| 54 |
headless: 'new'
|
| 55 |
}) :
|
| 56 |
await prb.connect({
|
| 57 |
+
customConfig: { executablePath },
|
|
|
|
|
|
|
| 58 |
disableXvfb: true,
|
| 59 |
headless: 'new',
|
| 60 |
turnstile: true
|
|
|
|
| 93 |
msg: format(e?.message || e)
|
| 94 |
})
|
| 95 |
} finally {
|
| 96 |
+
await (isGhost ? ctx : ctx.browser).close()
|
|
|
|
|
|
|
|
|
|
| 97 |
}
|
| 98 |
})
|
| 99 |
|