You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将Anti-captcha响应注入Supreme结账页reCAPTCHA表单?

Fixing reCAPTCHA Response Submission for Supreme Checkout

Let's break down why your current approach isn't working and get that captcha response properly submitted to complete the checkout.

What's Wrong With Your Current Code

Your method has two critical issues that are causing the submission to fail:

  • Over-removing reCAPTCHA infrastructure: Deleting the reCAPTCHA scripts, containers, and iframe breaks the page's expected validation flow. Supreme's backend or frontend likely checks for the presence of these elements or validates the captcha context that gets lost when you delete them.
  • Syntax error in response insertion: You added extra triple quotes (""") around the captcha response, which makes the value invalid before it even reaches the server. Plus, using a textarea instead of the hidden input that reCAPTCHA normally generates doesn't match what the server expects.

Step-by-Step Solution

Instead of stripping out reCAPTCHA entirely, we'll inject the response into the correct field and trigger the necessary events to make the page recognize the value. Here's how:

1. Target the Correct Hidden Field

reCAPTCHA v2 typically creates a hidden input element with either the name g-recaptcha-response or the class g-recaptcha-response. We'll use this existing field instead of creating a new textarea.

2. Inject the Response & Trigger Events

Once we locate the field, we'll set its value to your captcha response and trigger input/change events so the page's JavaScript knows the value has been updated.

Corrected Code Example

// Replace with your actual anti-captcha response (ensure it's a clean string)
const captcha_response = "your_valid_anti_captcha_response";

// Locate the hidden g-recaptcha-response field
const recaptchaInput = document.querySelector('input[name="g-recaptcha-response"]') || document.querySelector('.g-recaptcha-response');

if (recaptchaInput) {
  // Set the captcha response value
  recaptchaInput.value = captcha_response;
  
  // Trigger events to notify the page of the update
  recaptchaInput.dispatchEvent(new Event('input', { bubbles: true }));
  recaptchaInput.dispatchEvent(new Event('change', { bubbles: true }));
} else {
  // Fallback: If the field doesn't exist, create a hidden input before the checkout button
  const checkoutButton = document.querySelector('[name="commit"]');
  if (checkoutButton) {
    const hiddenCaptchaField = document.createElement('input');
    hiddenCaptchaField.type = 'hidden';
    hiddenCaptchaField.name = 'g-recaptcha-response';
    hiddenCaptchaField.value = captcha_response;
    checkoutButton.parentNode.insertBefore(hiddenCaptchaField, checkoutButton);
  }
}

Key Notes to Avoid Future Failures

  • Don't remove reCAPTCHA elements: Keeping the original scripts and iframe ensures the server sees a valid captcha context (matching sitekey, request origin, etc.). Removing them can trigger hidden validation checks that fail your request.
  • Double-check the response format: Make sure captcha_response is exactly the string returned by anti-captcha—no extra quotes, spaces, or formatting errors.
  • Inspect normal request parameters: Use your browser's Network tab to look at a successful manual checkout request. Check if there are other captcha-related fields (like recaptcha-token) that you might need to include, and ensure all other checkout fields (card details, shipping info) are correctly filled.

内容的提问来源于stack exchange,提问作者enrvate

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:00:47