-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtask.js
48 lines (45 loc) · 1.86 KB
/
task.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// check dashboard for accesskey
window.in_solving = false;
// for more details check https://bestcaptchasolver.com/captchabypass-api
function example_task() {
let ACCESS_TOKEN = 'ACCESS_TOKEN_HERE';
var captcha_id = undefined;
if(!in_solving) in_solving = true;
else return log('Doing another task currently');
document.getElementById('log').value = '';
bestcaptchasolverapi.set_access_token(ACCESS_TOKEN); // set token
// balance
bestcaptchasolverapi.account_balance().then(function (balance) {
log('Balance: $' + balance); // print balance gathered
log('Solving task');
return bestcaptchasolverapi.submit_task({
template_name: 'Login test page',
page_url: 'https://bestcaptchasolver.com/automation/login',
variables: {"username": "xyz", "password": "0000"},
// user_agent: 'your UA',
// proxy: '12.34.54.56:1234'
// affiliate_id: 'ID of affiliate'
});
}).then(id => {
// submit pushVariables while task is being solved by the worker
// very helpful, for e.g. in cases of 2FA authentication
// return bestcaptchasolverapi.task_push_variables(id, {"tfa_code": "49651"})
}).then(function (id) {
captcha_id = id;
log('Got ID ' + id + ', waiting for completion ...');
return bestcaptchasolverapi.retrieve_captcha(id);
}).then(function (data) {
log('Solution: ' + JSON.stringify(data.solution));
// return bestcaptchasolverapi.set_captcha_bad(captcha_id); // set captcha bad
}).catch(function (err) {
log(err.message || err);
}).then(function () {
in_solving = false;
log('Example finished !');
});
}
// log what's happening to UI and console
function log(txt) {
document.getElementById('log').value += txt + '\n';
console.log(txt);
}