Update CaptchaSolver.js
This commit is contained in:
parent
3e09cea4aa
commit
c69a4b327d
@ -34,18 +34,6 @@ const proxyParser = proxy => {
|
|||||||
return proxyConfig;
|
return proxyConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
function findStringWithRegex(obj, regex) {
|
|
||||||
const matchingKeys = [];
|
|
||||||
for (const key in obj) {
|
|
||||||
if (obj[key] && typeof obj[key] === 'object') {
|
|
||||||
matchingKeys.push(...findStringWithRegex(obj[key], regex));
|
|
||||||
} else if (typeof obj[key] === 'string' && regex.test(obj[key])) {
|
|
||||||
matchingKeys.push(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return matchingKeys;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = class CaptchaSolver {
|
module.exports = class CaptchaSolver {
|
||||||
constructor(service, key, defaultCaptchaSolver, proxyString = '') {
|
constructor(service, key, defaultCaptchaSolver, proxyString = '') {
|
||||||
this.service = 'custom';
|
this.service = 'custom';
|
||||||
@ -92,9 +80,11 @@ module.exports = class CaptchaSolver {
|
|||||||
this.solver
|
this.solver
|
||||||
.hcaptcha(siteKey, 'discord.com', postD)
|
.hcaptcha(siteKey, 'discord.com', postD)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let result = findStringWithRegex(res.data, /^P\d_\w+/)[0];
|
if (typeof res.data == 'string') {
|
||||||
if (!result) throw new Error('Invalid captcha response');
|
resolve(res.data);
|
||||||
resolve(result);
|
} else {
|
||||||
|
reject(new Error('Unknown Response'));
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user