Skip to content

Instantly share code, notes, and snippets.

@arronf2e
Created May 20, 2025 13:14
Show Gist options
  • Save arronf2e/88d6e991528cd542cb33f1614ff5a31f to your computer and use it in GitHub Desktop.
Save arronf2e/88d6e991528cd542cb33f1614ff5a31f to your computer and use it in GitHub Desktop.
const axios = require('axios')
const clientKey = ''
class YesCaptcha {
constructor(websiteURL, websiteKey, type = 'TurnstileTaskProxyless', pageAction = null) {
this.websiteKey = websiteKey
this.websiteURL = websiteURL
this.type = type
this.pageAction = pageAction
}
async createTask() {
const task = {
"type": this.type,
"websiteURL": this.websiteURL,
"websiteKey": this.websiteKey
}
if(this.pageAction) {
task.pageAction = this.pageAction
}
const res = await axios.post('https://api.yescaptcha.com/createTask', {
clientKey,
task,
})
return res?.data?.taskId;
}
async getTaskResult(taskId) {
while (true) {
const res = await axios.post('https://api.yescaptcha.com/getTaskResult', {
clientKey,
taskId,
});
if (res.data.status === 'ready') {
if(this.type === 'RecaptchaV3TaskProxyless') {
return res?.data?.solution?.gRecaptchaResponse
}
return res.data.solution.token;
}
// Wait for 3 seconds before polling again
await new Promise(resolve => setTimeout(resolve, 3000));
}
}
}
module.exports = YesCaptcha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment