Javascript callback to resolve hCaptcha

Zavavilyliar333

New member
Im a complete noob with JS coding and need to assistance to resolve hCaptcha.

Currently the site in question is coinhunt.cc, there are two Captcha, reCaptcha that i can resolve, however with hCaptcha i have no clue to get this resolved.

The current code can resolve the reCaptcha (I receive the token from 2Captcha and have a code that replaces the myjs with the token code):

Code:
document.getElementById("g-recaptcha-response").value="myjs"

function excuteCallback(obj, name) {

ret = null;

if (Object.hasOwnProperty(obj, name)) {

ret = Object.getOwnPropertyDescriptor(obj, name).value;

}

if (ret != null) {

return ret;

}

for (var objName in obj) {

var o=obj[objName];

if (o.hasOwnProperty(name)) {

ret = Object.getOwnPropertyDescriptor(o, name).value;

}

if (ret != null) {

return ret;

}

excuteCallback(o, name);

}

}

excuteCallback(window.___grecaptcha_cfg.clients[0], "callback")("myjs");

According to 2Captcha i require to to enter the return in both h-captcha-response and g-captcha-response, currently i am able to do this with the following:
Code:
document.getElementsByName("h-captcha-response").value="myjs"
document.getElementsByName("g-recaptcha-response").value="myjs"

However when i try to run this script i am greeted with the error:
javascript error: Cannot read property 'clients' of underfined

I dont know if the callback is correct or where to get the correct callback for hcaptcha from this site as said, im a noob and just starting to learn JS.
 

Rediker

New member
I think you are looking for the javascript to solve hCaptcha on Cloudflare protected website. If not this piece of code should work.

Code:
let frame = document.getElementById("hcaptcha_widget");

frame || (frame = document.getElementById("cf-hcaptcha-container")), t = document.getElementsByName("h-captcha-response"), t[0].innerHTML = "myjs", frame.closest("form").submit();

If it is cloudflare, they have changed the way the solution being submitted back recently. Details : https://2captcha.com/blog/hcaptcha-cloudflare-en You can refer to their chrome extension code which successfully solves the hcaptcha on cloudflare enabled websites. I could not derive the working js code as I'm also not js programmer. I think these two method on the 2captcha extension are relevant.

Code:
function doActionsOnSuccess(msg) {

    debugger;

    let widget = getWidgetInfo(msg.request.captchaType, msg.request.widgetId);

    let processor = CaptchaProcessors.get(msg.request.captchaType);

    processor.onSolved(widget, msg.response.code);

    Config.getAll().then(config => {

        let callback = processor.getCallback(widget);

        if (callback) {

            location.href = `javascript: window["${callback}"]("${msg.response.code}")`;

        }

        if (config.autoSubmitForms === true) {

            let timeout = parseInt(config.submitFormsDelay) * 1000;

            setTimeout(function() {

                processor.getForm(widget).submit();

            }, timeout);

        }

    });

}

onSolved: function(widget, answer) {

    let container = $("#" + widget.containerId);

    container.find("textarea").val(answer);

    container.find("iframe").attr("data-hcaptcha-response", answer);

},