Skip to content

Commit 24d0e14

Browse files
added task pushvariables feature
1 parent 680d2f8 commit 24d0e14

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

example/task.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ async function task() {
1818
const captchaID = await imagetyperzapi.submit_task(task_params)
1919
// solve captcha
2020
log('Waiting for captcha to be solved ...');
21+
22+
// # send pushVariable - update of variable while task is running (e.g 2FA code)
23+
// await imagetyperzapi.task_push_variables(captchaID, {twofactor_code: "32948"})
24+
2125
const response = await imagetyperzapi.retrieve_response(captchaID)
2226
log(`Response: ${JSON.stringify(response)}`)
2327
} catch (err) {

lib/imagetyperz-api-client.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ window.imagetyperz_config = {
1717
TIKTOK_ENDPOINT: 'http://captchatypers.com/captchaapi/UploadTikTokCaptchaUser.ashx',
1818
FUNCAPTCHA_ENDPOINT: 'http://captchatypers.com/captchaapi/UploadFunCaptcha.ashx',
1919
TASK_ENDPOINT: 'http://captchatypers.com/captchaapi/UploadCaptchaTask.ashx',
20+
TASK_PUSH_ENDPOINT: 'http://captchatypers.com/CaptchaAPI/SaveCaptchaPush.ashx',
2021

2122
CAPTCHA_ENDPOINT_CONTENT_TOKEN: 'http://captchatypers.com/Forms/UploadFileAndGetTextNEWToken.ashx',
2223
CAPTCHA_ENDPOINT_URL_TOKEN: 'http://captchatypers.com/Forms/FileUploadAndGetTextCaptchaURLToken.ashx',
@@ -507,6 +508,35 @@ imagetyperzapi.submit_task = function (d) {
507508
});
508509
};
509510

511+
// update task captcha pushVariables
512+
imagetyperzapi.task_push_variables = function (captcha_id, pushVariables) {
513+
var ic = imagetyperz_config; // get config obj
514+
return new Promise((resolve, reject) => {
515+
var data = {}
516+
if (ic.username && ic.password) {
517+
// legacy auth
518+
data['username'] = ic.username;
519+
data['password'] = ic.password;
520+
}
521+
else {
522+
data['token'] = ic.access_key; // token auth
523+
}
524+
525+
data['action'] = 'GETTEXT';
526+
data['captchaid'] = captcha_id
527+
data.pushVariables = JSON.stringify(pushVariables)
528+
529+
// make request
530+
$.post(ic.endpoints.TASK_PUSH_ENDPOINT, data).done(function (resp) {
531+
// check for error
532+
if (resp.indexOf('ERROR:') !== -1) return reject(resp);
533+
return resolve(resp);
534+
}).fail(function (err) {
535+
return reject(err);
536+
});
537+
});
538+
};
539+
510540
// retrieve recaptcha
511541
imagetyperzapi.retrieve_response = function (captcha_id) {
512542
var ic = imagetyperz_config; // get config obj

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "imagetyperz-api-client",
3-
"version": "1.2.8",
3+
"version": "1.2.9",
44
"description": "ImagetyperzAPI (client) is a super easy to use bypass captcha API wrapper for imagetyperz.com captcha service",
55
"main": "lib/imagetyperz-api-client.js",
66
"scripts": {

readme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,16 @@ captcha_params = {
237237
const captchaID = await imagetyperzapi.submit_task(captcha_params)
238238
```
239239

240+
#### Task pushVariable
241+
Update a variable value while task is running. Useful when dealing with 2FA authentication.
240242

243+
When template reaches an action that uses a variable which wasn't provided with the submission of the task,
244+
task (while running on worker machine) will wait for variable to be updated through push.
245+
246+
You can use the pushVariables method as many times as you need, even overwriting previously set variables.
247+
```javascript
248+
await imagetyperzapi.task_push_variables(captchaID, {twofactor_code: "32948"})
249+
```
241250

242251
## Retrieve response
243252

0 commit comments

Comments
 (0)