This repository was archived by the owner on May 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathrecaptcha_voice.js
150 lines (150 loc) · 4.38 KB
/
recaptcha_voice.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
;(async () => {
class r {
static time () {
return Date.now || (Date.now = () => new Date().getTime()), Date.now()
}
static sleep (t = 1e3) {
return new Promise(e => setTimeout(e, t))
}
static async random_sleep (e, t) {
t = Math.floor(Math.random() * (t - e) + e)
return r.sleep(t)
}
static pad (e) {
var t = 2 - String(e).length + 1
return 0 < t ? '' + new Array(t).join('0') + e : '' + e
}
static date () {
return new Date()
}
static string (e = null) {
return (
(e = e || r.date()),
r.pad(e.getMonth() + 1) +
`/${r.pad(e.getDate())}/${e.getFullYear()} ${r.pad(
e.getHours() % 12
)}:${r.pad(e.getMinutes())}:${r.pad(e.getSeconds())} ` +
(12 <= e.getHours() ? 'PM' : 'AM')
)
}
}
class n {
static exec (e, a) {
return new Promise(t => {
try {
chrome.runtime.sendMessage({ method: e, data: a }, t)
} catch (e) {
t()
}
})
}
}
class o {
static async fetch (e, t) {
return n.exec('fetch', { url: e, options: t })
}
}
function i () {
var e, t
if (!l())
return (
(e =
'true' ===
document
.querySelector('.recaptcha-checkbox')
?.getAttribute('aria-checked')),
(t = document.querySelector('#recaptcha-verify-button')?.disabled),
e || t
)
}
function l () {
return (
'Try again later' ===
document.querySelector('.rc-doscaptcha-header')?.innerText
)
}
async function e (e) {
i() ||
(await r.sleep(e.recaptcha_open_delay),
document.querySelector('#recaptcha-anchor')?.click())
}
async function t (t) {
var a = await n.exec('get_cache', {
name: 'recaptcha_visible',
tab_specific: true
})
if (true === a && !i())
if (l()) await n.exec('reset_recaptcha')
else {
;(a = document.querySelector('.rc-audiochallenge-tdownload-link')
?.href),
(a =
(fetch(a),
document
.querySelector('#audio-source')
?.src?.replace('recaptcha.net', 'google.com')))
let e = document
.querySelector('html')
?.getAttribute('lang')
?.trim()
;(e && 0 !== e.length) || (e = 'en')
var c = r.time(),
a = await o.fetch('https://engageub.pythonanywhere.com', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: 'input=' + encodeURIComponent(a) + '&lang=' + e
}),
a =
((document.querySelector('#audio-response').value = a),
t.recaptcha_solve_delay - (r.time() - c))
0 < a && (await r.sleep(a)),
document.querySelector('#recaptcha-verify-button')?.click()
}
}
for (;;) {
await r.sleep(1e3)
var a = await n.exec('get_settings')
a &&
'voice' === a.recaptcha_solve_method &&
((async function () {
var t = document.querySelectorAll(
'iframe[src*="/recaptcha/api2/bframe"]'
)
if (0 < t.length) {
let e = false
for (const a of t)
if ((e = 'visible' === window.getComputedStyle(a).visibility)) break
e
? await n.exec('set_cache', {
name: 'recaptcha_visible',
value: true,
tab_specific: true
})
: await n.exec('set_cache', {
name: 'recaptcha_visible',
value: false,
tab_specific: true
})
}
})(),
a.recaptcha_auto_open &&
null !== document.querySelector('.recaptcha-checkbox')
? await e(a)
: a.recaptcha_auto_solve &&
null !== document.querySelector('.rc-imageselect-instructions')
? ((c = a),
await (true ===
(await n.exec('get_cache', {
name: 'recaptcha_visible',
tab_specific: true
})) &&
!i() &&
(await r.sleep(c.recaptcha_open_delay),
!document.querySelector('#recaptcha-audio-button')?.click())))
: !a.recaptcha_auto_solve ||
(null === document.querySelector('#audio-instructions') &&
null === document.querySelector('.rc-doscaptcha-header')) ||
(await t(a)))
}
var c
})()