This commit is contained in:
spiduler
2020-11-09 09:48:11 +09:00
parent ac0a53aead
commit 491b7c5c03

View File

@@ -67,12 +67,16 @@ class CaptchaComp {
return fetch(this.getUrl(params), this.getParams()).then(res => res.json())
}
getSiteKey(src) {
let keys = ['k', 'sitekey']
let q = url.parse(src, true).query
keys = keys.map(key => q[key]).filter(k => k)
return keys.length ? keys[0] : logger.throwError('Googlekey not found', { src: src })
}
requestResolve(driver) {
return driver.findElement(By.css('#hcaptcha iframe')).getAttribute('src')
.then(src => {
let googlekey = url.parse(src, true).query.k
if (!googlekey) logger.throwError('Googlekey not found', { src: src })
})
.then(src => this.getSiteKey(src))
.then(googlekey => {
return driver.getCurrentUrl().then(pageurl => {
return this.request({ googlekey: googlekey, pageurl: pageurl }).then(res => {
@@ -95,7 +99,7 @@ class CaptchaComp {
while (res.request == 'CAPCHA_NOT_READY') {
logger.info('Retry get recap answer in %d senconds', this.api.retryTimeout / 1000)
await this.sleep(this.api.retryTimeout)
retryLimit = retryLimit - 1
retryLimit = retryLimit - 1
res = await this.request({ id: id })
if (retryLimit == 0) break
}