-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtask.js
32 lines (29 loc) · 1.35 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
// task parameters
var task_params = {}
task_params.template_name = 'Login test page'
task_params.page_url = 'https://imagetyperz.net/automation/login'
task_params.variables = {username: 'abc', password: 'paZZW0rd'}
// task_params.proxy = '126.45.34.53:123'; // optional
// task_params.user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0'; // optional
async function task() {
try {
// clear log box
document.getElementById('log').value = '';
// authenticate with token
imagetyperzapi.set_access_key(document.getElementById('token').value);
// get account balance
const balance = await imagetyperzapi.account_balance()
log('Balance: $' + balance); // print balance gathered
const captchaID = await imagetyperzapi.submit_task(task_params)
// solve captcha
log('Waiting for captcha to be solved ...');
// # send pushVariable - update of variable while task is running (e.g 2FA code)
// await imagetyperzapi.task_push_variables(captchaID, {twofactor_code: "32948"})
const response = await imagetyperzapi.retrieve_response(captchaID)
log(`Response: ${JSON.stringify(response)}`)
} catch (err) {
log(`Error: ${err.message || err}`)
} finally {
log('Example finished !')
}
}