Currently hCaptcha and reCaptcha have a lot of duplicated code that are unnecessary.
Instead, those code can be merged into a class and let hCaptcha and reCaptcha extend them.
This will reduce the maintenance needed for those extensions, and also allow easier implementation for other script-based Captcha, like SliderCaptcha (T273572) and Turnstile (T319068).
See also: T208829: Implement support for new Google ReCaptcha v3