semuthitamku commited on
Commit
bc65ff0
·
verified ·
1 Parent(s): 337fb33

Update worker.js

Browse files
Files changed (1) hide show
  1. worker.js +9 -6
worker.js CHANGED
@@ -1,27 +1,30 @@
1
  const { parentPort } = require('node:worker_threads')
2
- const playwright = require('playwright')
 
3
 
4
- const runUserScript = async (browser, code) => {
5
  const AsyncFunction =
6
  Object.getPrototypeOf(async function () {}).constructor
7
 
8
  const userFunc = new AsyncFunction(
9
  'playwright',
 
10
  'console',
11
  code
12
  )
13
 
14
  return await userFunc(
15
- browser,
 
16
  console
17
  )
18
  }
19
 
20
  parentPort.on('message', async (code) => {
21
  try {
22
- const result = await runUserScript(playwright, code)
23
  parentPort.postMessage({ result })
24
- } catch (e) {
25
- parentPort.postMessage({ error: e })
26
  }
27
  })
 
1
  const { parentPort } = require('node:worker_threads')
2
+ const playwright = require('playwright-extra')
3
+ const pluginStealth = require('puppeteer-extra-plugin-stealth')
4
 
5
+ const runUserScript = async (code) => {
6
  const AsyncFunction =
7
  Object.getPrototypeOf(async function () {}).constructor
8
 
9
  const userFunc = new AsyncFunction(
10
  'playwright',
11
+ 'pluginStealth'
12
  'console',
13
  code
14
  )
15
 
16
  return await userFunc(
17
+ playwright,
18
+ pluginStealth,
19
  console
20
  )
21
  }
22
 
23
  parentPort.on('message', async (code) => {
24
  try {
25
+ const result = await runUserScript(code)
26
  parentPort.postMessage({ result })
27
+ } catch (error) {
28
+ parentPort.postMessage({ error })
29
  }
30
  })