From 63a64c77781ec27dc3711794cb56d4cbbe104b8e Mon Sep 17 00:00:00 2001 From: Maxim S Date: Tue, 2 Jun 2026 14:12:12 +0200 Subject: [PATCH] added yidun captcha --- README.md | 28 +++++++++++ examples/yidun.js | 23 +++++++++ package.json | 3 +- src/structs/2captcha.ts | 82 ++++++++++++++++++++++++++++++++- src/utils/checkCaptchaParams.ts | 6 ++- src/utils/renameParams.ts | 6 ++- 6 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 examples/yidun.js diff --git a/README.md b/README.md index a40a4a2..039a634 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ Examples of API requests for different captcha types are available on the [JavaS - [Altcha](#altcha) - [Binance](#binance) - [Audio Captcha](#audio-captcha) + - [Yidun NECaptcha](#yidun-necaptcha) - [Other methods](#other-methods) - [goodReport](#goodreport) - [badReport](#badreport) @@ -801,6 +802,33 @@ solver.audio({ }) ``` +### Yidun NECaptcha + +[API method description.](https://2captcha.com/2captcha-api#yidun) + +This method can be used to solve Yidun NECaptcha. Returns a token. + +```js +solver.yidun({ + pageurl: "https://mysite.com/page/with/yidun", + sitekey: "your_site_key", + userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36", + yidunGetLib: "https://cstaticdun.126.net/load.min.js", + yidunApiServerSubdomain: "cstaticdun.126.net", + challenge: "12345678abc90123d4567ef8a9012345", + hcg: "your_hcg_value", + hct: 1234567890, + proxy: "login:password@1.2.3.4:8888", + proxytype: "HTTP" +}) +.then((res) => { +console.log(res); +}) +.catch((err) => { +console.log(err); +}) +``` + ## Other methods ### goodReport diff --git a/examples/yidun.js b/examples/yidun.js new file mode 100644 index 0000000..b65ae63 --- /dev/null +++ b/examples/yidun.js @@ -0,0 +1,23 @@ +const TwoCaptcha = require("../dist/index.js"); +require('dotenv').config(); +const APIKEY = process.env.APIKEY +const solver = new TwoCaptcha.Solver(APIKEY); + +solver.yidun({ + pageurl: "https://mysite.com/page/with/yidun", + sitekey: "your_site_key", + userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36", + yidunGetLib: "https://cstaticdun.126.net/load.min.js", + yidunApiServerSubdomain: "cstaticdun.126.net", + challenge: "12345678abc90123d4567ef8a9012345", + hcg: "your_hcg_value", + hct: 1234567890, + proxy: "login:password@1.2.3.4:8888", + proxytype: "HTTP" +}) +.then((res) => { +console.log(res); +}) +.catch((err) => { +console.log(err); +}) diff --git a/package.json b/package.json index b31598e..bf493fe 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,8 @@ "atbCAPTCHA", "Altcha", "Binance", - "Audio Recognition" + "Audio Recognition", + "Yidun NECaptcha" ], "scripts": { "build": "tsc && node ./dist/index.js", diff --git a/src/structs/2captcha.ts b/src/structs/2captcha.ts index f62d353..1713904 100644 --- a/src/structs/2captcha.ts +++ b/src/structs/2captcha.ts @@ -325,6 +325,19 @@ export interface paramsAudioCaptcha { pingback?: string, } +export interface paramsYidun { + pageurl: string, + sitekey: string, + userAgent?: string, + yidunGetLib?: string, + yidunApiServerSubdomain?: string, + challenge?: string, + hcg?: string, + hct?: number, + proxy?: string, + proxytype?: string, +} + /** * An object containing properties of the captcha solution. * @typedef {Object} CaptchaAnswer @@ -2338,14 +2351,79 @@ public async audio(params: paramsAudioCaptcha): Promise { } } +/** + * ### Solves Yidun NECaptcha + * + * This method can be used to solve Yidun NECaptcha. Returns a token. + * [Read more about Yidun NECaptcha Method](https://2captcha.com/2captcha-api#yidun). + * + * @param {{ pageurl, sitekey, userAgent, yidunGetLib, yidunApiServerSubdomain, challenge, hcg, hct, proxy, proxytype }} params Parameters Yidun NECaptcha as an object. + * @param {string} params.pageurl Full URL of the page where you see the captcha. + * @param {string} params.sitekey The value of `id` or `sitekey` parameter found on the page. + * @param {string} params.userAgent Optional. Browser User-Agent string. + * @param {string} params.yidunGetLib Optional. URL of the JavaScript file used to load the captcha. + * @param {string} params.yidunApiServerSubdomain Optional. Custom API server subdomain. + * @param {string} params.challenge Optional. Dynamic challenge value obtained from network requests. + * @param {string} params.hcg Optional. Captcha hash value. + * @param {number} params.hct Optional. Numeric timestamp identifier. + * @param {string} params.proxy Optional. Format: `login:password@123.123.123.123:3128`. You can find more info about proxies [here](https://2captcha.com/2captcha-api#proxies). + * @param {string} params.proxytype Optional. Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`. + * + * @returns {Promise} The result from the solve. + * @throws APIError + * + * @example + * solver.yidun({ + * pageurl: "https://mysite.com/page/with/yidun", + * sitekey: "your_site_key" + * }) + * .then((res) => { + * console.log(res); + * }) + * .catch((err) => { + * console.log(err); + * }) + */ +public async yidun(params: paramsYidun): Promise { + params = renameParams(params) + + checkCaptchaParams(params, "yidun") + + const payload = { + ...this.defaultPayload, + ...params, + method: "yidun", + }; + + const response = await fetch(this.in, { + body: JSON.stringify(payload), + method: "post", + headers: { "Content-Type": "application/json" } + }) + const result = await response.text() + + let data; + try { + data = JSON.parse(result) + } catch { + throw new APIError(result) + } + + if (data.status == 1) { + return this.pollResponse(data.request) + } else { + throw new APIError(data.request) + } +} + /** * Reports a captcha as correctly solved. - * + * * @param {string} id The ID of the captcha * @throws APIError * @example * solver.goodReport("7031854546") - * + * */ public async goodReport(id: string): Promise { const payload = { diff --git a/src/utils/checkCaptchaParams.ts b/src/utils/checkCaptchaParams.ts index 18bb43a..bafc379 100644 --- a/src/utils/checkCaptchaParams.ts +++ b/src/utils/checkCaptchaParams.ts @@ -1,7 +1,7 @@ // Captcha methods for which parameter checking is available const supportedMethods = ["userrecaptcha", "hcaptcha", "geetest", "geetest_v4","yandex","funcaptcha","lemin","amazon_waf", "turnstile", "base64", "capy","datadome", "cybersiara", "mt_captcha", "bounding_box", 'friendly_captcha', 'grid', - 'textcaptcha', 'canvas', 'rotatecaptcha', 'keycaptcha', 'cutcaptcha', 'tencent', 'atb_captcha', 'prosopo', 'captchafox', 'vkimage', 'vkcaptcha', 'temu', 'altcha', 'binance', 'audio'] + 'textcaptcha', 'canvas', 'rotatecaptcha', 'keycaptcha', 'cutcaptcha', 'tencent', 'atb_captcha', 'prosopo', 'captchafox', 'vkimage', 'vkcaptcha', 'temu', 'altcha', 'binance', 'audio', 'yidun'] // Names of required fields that must be contained in the parameters captcha const recaptchaRequiredFields = ['pageurl','googlekey'] @@ -37,6 +37,7 @@ const temuRequiredFields = ['body', 'part1', 'part2', 'part3'] const altchaRequiredFields = ['pageurl'] const binanceRequiredFields = ['pageurl', 'sitekey', 'validate_id'] const audioRequiredFields = ['body', 'lang'] +const yidunRequiredFields = ['pageurl', 'sitekey'] /** * Getting required arguments for a captcha. @@ -144,6 +145,9 @@ const getRequiredFildsArr = (method: string):Array => { case "audio": requiredFieldsArr = audioRequiredFields break; + case "yidun": + requiredFieldsArr = yidunRequiredFields + break; } return requiredFieldsArr } diff --git a/src/utils/renameParams.ts b/src/utils/renameParams.ts index 7d7bb7d..8d84f12 100644 --- a/src/utils/renameParams.ts +++ b/src/utils/renameParams.ts @@ -46,7 +46,11 @@ export default function renameParams(params: any) { //Binance "validateId": "validate_id", - "userAgent": "useragent" + "userAgent": "useragent", + + // Yidun + "yidunGetLib": "yidun_get_lib", + "yidunApiServerSubdomain": "yidun_api_server_subdomain" } for(let key in params) {