Created
May 20, 2025 13:14
-
-
Save arronf2e/88d6e991528cd542cb33f1614ff5a31f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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