- // ==UserScript==
- // @name Captcha Configuration Layer
- // @namespace http://your-namespace.com
- // @version 1.0
- // @description Complete configuration for all captcha types
- // ==/UserScript==
-
- const Config = {
- // 基础API配置
- API: {
- ENDPOINT: "http://api.jfbym.com/api/YmServer/customApi",
- DEFAULT_TIMEOUT: 20000, // 20秒
- CONTENT_TYPES: {
- JSON: "application/json",
- FORM: "application/x-www-form-urlencoded"
- }
- },
-
- // 全量验证码类型配置(基于文档1 37个接口)
- CAPTCHA_TYPES: {
- // █████ 通用数英类(12种)█████
- GENERAL_NUM_EN_1_4: {
- type: "10103",
- name: "通用数英1-4位基础版",
- params: {
- image: "", // Base64图片
- token: "", // 用户令牌
- extra: "" // 扩展参数
- },
- pricing: {
- base: 12, // 基础价格
- tiers: { // 阶梯价格
- 4: 12, // <=4位
- 6: 15 // <=6位(当基础版失败时升级)
- }
- },
- fallback: "GENERAL_NUM_EN_HUMAN_1_20" // 上位接口
- },
-
- GENERAL_NUM_EN_HUMAN_1_20: {
- type: "50103",
- name: "人机混合数英1-20位",
- params: {
- image: "",
- token: "",
- hybrid_mode: true // 人机混合标志
- },
- pricing: {
- tiers: { // 详细阶梯定价
- 5: 12, 6:15, 7:18, 8:20,
- 9:23, 10:25, 12:30, 20:50
- }
- },
- timeout: 30000 // 人工识别延长超时
- },
-
- // ...其他数英变体...
- GENERAL_NUM_EN_5_8: {
- type: "10105",
- name: "通用数英5-8位",
- params: {
- image: "",
- token: "",
- length_range: [5,8] // 显式长度限制
- }
- },
-
- GENERAL_NUM_EN_12_PLUS: {
- type: "10120",
- name: "通用数英12位+",
- params: {
- image: "",
- token: "",
- strict_mode: true // 严格校验模式
- }
- },
-
- // █████ 特殊定制类(8种)█████
- CASE_SENSITIVE: {
- type: "20110",
- name: "区分大小写定制版",
- params: {
- image: "",
- token: "",
- case_sensitive: true, // 大小写区分
- template_match: true // 需匹配示例图
- }
- },
-
- COLOR_FILTER: {
- type: "20205",
- name: "指定颜色字符",
- params: {
- image: "",
- token: "",
- color: "red", // 支持red/blue/yellow/all
- filter_type: "exact" // 精确颜色匹配
- }
- },
-
- // ...其他定制类型...
- DYNAMIC_BG: {
- type: "20301",
- name: "动态背景适配",
- params: {
- image: "",
- token: "",
- bg_complexity: 3 // 背景复杂度等级
- }
- },
-
- // █████ 计算题类(6种)█████
- MATH_CHINESE: {
- type: "30101",
- name: "中文计算题",
- params: {
- image: "",
- token: "",
- lang: "zh-CN" // 语言标识
- }
- },
-
- MATH_NUMERIC: {
- type: "30201",
- name: "数字计算题",
- params: {
- image: "",
- token: "",
- max_operands: 3 // 最大操作数
- }
- },
-
- // █████ 滑块类(11种)█████
- SLIDE_DOUBLE: {
- type: "40101",
- name: "双图滑块",
- params: {
- bg_image: "", // 背景图
- slice_image: "", // 滑块图
- token: ""
- },
- calibration: { // 校准参数
- base_ratio: 0.82, // 基础比例
- offset: 5, // 像素偏移
- formula: raw => Math.round(raw * 0.82 + 5)
- }
- },
-
- SLIDE_SINGLE: {
- type: "40201",
- name: "单图滑块",
- params: {
- image: "",
- token: "",
- detection_mode: "edge" // 边缘检测模式
- },
- calibration: {
- base_ratio: 1.15,
- offset: -3,
- formula: raw => Math.abs(raw * 1.15 - 3)
- }
- },
-
- // ...其他滑块变体...
- BEHAVIOR_SLIDE: {
- type: "40305",
- name: "行为验证滑块",
- params: {
- image: "",
- token: "",
- behavior_data: "" // 行为轨迹数据
- }
- },
-
- // █████ 错误处理配置 █████
- ERROR_CODES: {
- 10000: { level: "success", msg: "识别成功" },
- 10002: {
- level: "critical",
- msg: "余额不足",
- action: "recharge|stop"
- },
- 10007: {
- level: "warning",
- msg: "服务繁忙",
- retry: {
- max_attempts: 3,
- backoff: [1000, 3000, 5000] // 重试间隔
- }
- },
- // ...其他错误码...
- 10010: {
- level: "info",
- msg: "请求结束",
- action: "refresh_captcha"
- }
- },
-
- // █████ 高级安全配置 █████
- SECURITY: {
- IMAGE_VALIDATION: {
- MIN_WIDTH: 80, // 最小图片宽度
- MIN_HEIGHT: 30, // 最小图片高度
- MAX_SIZE: 1.5 * 1024 * 1024, // 1.5MB
- ALLOWED_FORMATS: ["jpg", "png", "webp"]
- },
- REQUEST_SIGNING: {
- ENABLED: true,
- VERSION: "v2",
- ALGORITHM: "HMAC-SHA256",
- TIMESTAMP_WINDOW: 5000 // 5秒有效期
- }
- }
- },
-
- // █████ 运行时配置 █████
- RUNTIME: {
- AUTO_SWITCH_THRESHOLD: 0.65, // 识别置信度阈值
- HUMAN_FALLBACK_DELAY: 15000, // 人工识别等待时间
- ELEMENT_DETECTION: {
- SCAN_INTERVAL: 3000, // 元素检测间隔
- CAPTCHA_KEYWORDS: [ // 验证码特征关键词
- "captcha", "yzm", "verification",
- "验证码", "安全校验", "人机验证"
- ]
- }
- }
- };
-
- /* 配置验证函数 */
- function validateConfig() {
- // 类型存在性检查
- const REQUIRED_TYPES = [
- 'GENERAL_NUM_EN_1_4',
- 'SLIDE_DOUBLE',
- 'MATH_CHINESE'
- ];
-
- // 参数完整性检查
- const validateParams = (typeConfig) => {
- const requiredParams = ['type', 'name', 'params'];
- return requiredParams.every(param => param in typeConfig);
- };
-
- // 执行验证
- try {
- REQUIRED_TYPES.forEach(type => {
- if (!Config.CAPTCHA_TYPES[type]) {
- throw new Error(`Missing required captcha type: ${type}`);
- }
- if (!validateParams(Config.CAPTCHA_TYPES[type])) {
- throw new Error(`Invalid configuration for type: ${type}`);
- }
- });
- console.log("Config validation passed");
- } catch (e) {
- console.error("Config validation failed:", e);
- }
- }
-
- // 初始化时自动验证
- validateConfig();