Spaces:
Paused
Paused
| const { parentPort } = require('node:worker_threads') | |
| const playwright = require('playwright-extra') | |
| const pluginStealth = require('puppeteer-extra-plugin-stealth') | |
| const runUserScript = async (code) => { | |
| const AsyncFunction = | |
| Object.getPrototypeOf(async function () {}).constructor | |
| const userFunc = new AsyncFunction( | |
| 'playwright', | |
| 'pluginStealth', | |
| 'console', | |
| code | |
| ) | |
| return await userFunc( | |
| playwright, | |
| pluginStealth, | |
| console | |
| ) | |
| } | |
| parentPort.on('message', async (code) => { | |
| try { | |
| const result = await runUserScript(code) | |
| parentPort.postMessage({ result }) | |
| } catch (error) { | |
| parentPort.postMessage({ error }) | |
| } | |
| }) |