berstend / puppeteer-extra

💯 Teach puppeteer new tricks through plugins.
https://extra.community
MIT License
6.42k stars 739 forks source link

fix(plugin-recaptcha): Support esbuild transpilation of content scripts #758

Closed igalklebanov closed 1 year ago

igalklebanov commented 1 year ago

This one was a real pain in the *@#^@. But now the sun can shine once again, and the scraping can continue!

Basically, was having a blast running plugin-recaptcha locally with ts-node, and once the same code hit production aws lambdas it started throwing the mentioned error.

Long story short, it was esbuild and the way it transformed RecaptchaContentScript & HcaptchaContentScript classes into something like var HcaptchaContentScript = class {.

The fix looks for such a sequence and injects the class name back.

transitive-bullshit commented 1 year ago

Also running into this on https://github.com/transitive-bullshit/chatgpt-api

I ended up switching captcha providers because it wouldn't work when invoked via tsx (which uses esbuild under the hood).

igalklebanov commented 1 year ago

I think I tried tsx too, but either it didn't work because of this issue or something with decorators. So went with ts-node because well, build is not as slow as waiting for hcaptcha provider's response.

berstend commented 1 year ago

@igalklebanov great find 👍

I'll try to merge this in before merging #763, for attribution :)

berstend commented 1 year ago
Successfully published:
 - puppeteer-extra-plugin-recaptcha@3.6.8