Skip to content

Commit 6753162

Browse files
updated lib, examples and readme
1 parent a740638 commit 6753162

16 files changed

+505
-334
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea
2+
node_modules

example/capy.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// recaptcha parameters
2+
var captcha_params = {};
3+
captcha_params.page_url = 'https://your-site.com';
4+
captcha_params.sitekey = 'Fme6hZLjuCRMMC3uh15F52D3uNms5c';
5+
// captcha_params.proxy = '126.45.34.53:123'; // optional
6+
// captcha_params.user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0'; // optional
7+
8+
async function capy() {
9+
try {
10+
// clear log box
11+
document.getElementById('log').value = '';
12+
// authenticate with token
13+
imagetyperzapi.set_access_key(document.getElementById('token').value);
14+
// get account balance
15+
const balance = await imagetyperzapi.account_balance()
16+
log('Balance: $' + balance); // print balance gathered
17+
const captchaID = await imagetyperzapi.submit_capy(captcha_params)
18+
// solve captcha
19+
log('Waiting for captcha to be solved ...');
20+
const response = await imagetyperzapi.retrieve_response(captchaID)
21+
log(`Response: ${JSON.stringify(response)}`)
22+
} catch (err) {
23+
log(`Error: ${err.message || err}`)
24+
} finally {
25+
log('Example finished !')
26+
}
27+
}

example/example.html

Lines changed: 0 additions & 28 deletions
This file was deleted.

example/example.js

Lines changed: 0 additions & 98 deletions
This file was deleted.

example/geetest.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var captcha_params = {};
2+
captcha_params.domain = 'https://your-site.com';
3+
captcha_params.challenge = 'eea8d7d1bd1a933d72a9eda8af6d15d3';
4+
captcha_params.gt = '1a761081b1114c388092c8e2fd7f58bc';
5+
//captcha_params.proxy = '126.45.34.53:123'; // optional
6+
//captcha_params.user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0'; // optional
7+
8+
async function geetest() {
9+
try {
10+
// clear log box
11+
document.getElementById('log').value = '';
12+
// authenticate with token
13+
imagetyperzapi.set_access_key(document.getElementById('token').value);
14+
// get account balance
15+
const balance = await imagetyperzapi.account_balance()
16+
log('Balance: $' + balance); // print balance gathered
17+
const captchaID = await imagetyperzapi.submit_geetest(captcha_params)
18+
// solve captcha
19+
log('Waiting for captcha to be solved ...');
20+
const response = await imagetyperzapi.retrieve_response(captchaID)
21+
log(`Response: ${JSON.stringify(response)}`)
22+
} catch (err) {
23+
log(`Error: ${err.message || err}`)
24+
} finally {
25+
log('Example finished !')
26+
}
27+
}

example/hcaptcha.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// recaptcha parameters
2+
var captcha_params = {};
3+
captcha_params.page_url = 'https://your-site.com';
4+
captcha_params.sitekey = '8c7062c7-cae6-4e12-96fb-303fbec7fe4f';
5+
// captcha_params.proxy = '126.45.34.53:123'; // optional
6+
// captcha_params.user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0'; // optional
7+
8+
async function hcaptcha() {
9+
try {
10+
// clear log box
11+
document.getElementById('log').value = '';
12+
// authenticate with token
13+
imagetyperzapi.set_access_key(document.getElementById('token').value);
14+
// get account balance
15+
const balance = await imagetyperzapi.account_balance()
16+
log('Balance: $' + balance); // print balance gathered
17+
const captchaID = await imagetyperzapi.submit_hcaptcha(captcha_params)
18+
// solve captcha
19+
log('Waiting for captcha to be solved ...');
20+
const response = await imagetyperzapi.retrieve_response(captchaID)
21+
log(`Response: ${JSON.stringify(response)}`)
22+
} catch (err) {
23+
log(`Error: ${err.message || err}`)
24+
} finally {
25+
log('Example finished !')
26+
}
27+
}

example/image.js

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/index.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Imagetyperz API example - javascript client version</title>
6+
<style>
7+
textarea{
8+
width: 100%;
9+
}
10+
button{
11+
width: 100%;
12+
height: 60px;
13+
font-size: 20px;
14+
}
15+
select, input {
16+
width: 100%;
17+
}
18+
</style>
19+
<script>
20+
// log what's happening to UI and console
21+
function log(txt) {
22+
document.getElementById('log').value += txt + '\n';
23+
console.log(txt);
24+
}
25+
// run captcha type example based on input selection
26+
function run () {
27+
const cType = document.getElementById('captcha-type').value
28+
if (cType === 'image') image()
29+
else if (cType === 'recaptcha') recaptcha()
30+
else if (cType === 'hcaptcha') hcaptcha()
31+
else if (cType === 'geetest') geetest()
32+
else if (cType === 'capy') capy()
33+
else if (cType === 'tiktok') tiktok()
34+
else log(`Unknown captcha type: ${cType}`)
35+
}
36+
</script>
37+
</head>
38+
<body>
39+
<!-- Element for logging data -->
40+
<textarea id='log' rows=10 autofocus></textarea>
41+
<input type="text" id="token" placeholder="Access token from https://imagetyperz.com" value=""/>
42+
<select id="captcha-type">
43+
<option value="image">image (examples/image.js)</option>
44+
<option value="recaptcha">reCAPTCHA (examples/recaptcha.js)</option>
45+
<option value="hcaptcha">hCaptcha (examples/hcaptcha.js)</option>
46+
<option value="geetest">Geetest (examples/geetest.js)</option>
47+
<option value="capy">Capy (examples/capy.js)</option>
48+
<option value="tiktok">Tiktok (examples/tiktok.js)</option>
49+
</select>
50+
<button onclick="run()">Run example</button>
51+
<!-- Load jQuery (dependency) -->
52+
<script src="../vendor/jquery.js"></script>
53+
<!-- Load the library -->
54+
<script src="../lib/imagetyperz-api-client.js"></script>
55+
<!-- Examples (for each captcha type) -->
56+
<script src="image.js"></script>
57+
<script src="recaptcha.js"></script>
58+
<script src="geetest.js"></script>
59+
<script src="capy.js"></script>
60+
<script src="hcaptcha.js"></script>
61+
<script src="tiktok.js"></script>
62+
</body>
63+
</html>

0 commit comments

Comments
 (0)