xpzouying/xiaohongshu-mcp · error

声明原创按钮仍处于禁用状态

Error message

声明原创按钮仍处于禁用状态

What it means

After enabling the original-declaration switch, XHS shows a confirmation dialog requiring the user to check a notice checkbox before the '声明原创' button becomes clickable. confirmOriginalDeclaration retries checking the footer checkbox once and, if isButtonDisabled(btn) still reports the button disabled, throws this error. It means the declaration could not be confirmed interactively.

Source

Thrown at xiaohongshu/publish.go:1064

	footer, err := findFooterByText(page, "声明原创")
	if err != nil {
		return errors.Wrap(err, "未找到声明原创弹窗")
	}

	btn, err := footer.Element("button.custom-button")
	if err != nil {
		return errors.Wrap(err, "未找到声明原创按钮")
	}

	if isButtonDisabled(btn) {
		// 兜底:按钮仍禁用,可能须知未勾上,再勾一次
		if err := checkFooterCheckbox(footer); err != nil {
			slog.Warn("二次勾选须知失败", "error", err)
		}
		time.Sleep(300 * time.Millisecond)
		if isButtonDisabled(btn) {
			return errors.New("声明原创按钮仍处于禁用状态")
		}
	}

	if err := humanize.Click(btn); err != nil {
		return errors.Wrap(err, "点击声明原创按钮失败")
	}
	slog.Info("已成功点击声明原创按钮")
	time.Sleep(300 * time.Millisecond)
	return nil
}

func findFooterByText(page *rod.Page, keyword string) (*rod.Element, error) {
	footers, err := page.Elements("div.footer")
	if err != nil {
		return nil, errors.Wrap(err, "查找弹窗 footer 失败")
	}
	for _, footer := range footers {
		text, err := footer.Text()

View on GitHub (pinned to 332d196854)

Solutions

  1. Inspect the dialog DOM and ensure checkFooterCheckbox clicks the actual hit target (inner input/label) of the custom checkbox
  2. Increase the post-check sleep or use rod's WaitDisabled/WaitEnabled on the button instead of fixed sleeps
  3. Use humanize/real-mouse click for the checkbox as well, not just for the confirm button
  4. Capture a screenshot on failure to see whether the dialog state differs (e.g. additional agreement items required)

Example fix

// before
if isButtonDisabled(btn) {
	return errors.New("声明原创按钮仍处于禁用状态")
}
// after
if err := btn.WaitEnabled(5 * time.Second); err != nil {
	return errors.Wrap(err, "声明原创按钮仍处于禁用状态")
}
Defensive patterns

Strategy: retry

Try / catch

if err := confirmOriginalDeclaration(page); err != nil {
	if strings.Contains(err.Error(), "仍处于禁用状态") {
		time.Sleep(1 * time.Second)
		return confirmOriginalDeclaration(page) // 重试一次勾选+确认
	}
	return err
}

Prevention

When it happens

Trigger: setOriginal → confirmOriginalDeclaration; the notice checkbox check didn't register (custom checkbox needing real mouse events, wrong element clicked) so the confirm button's disabled state never cleared even after the second attempt.

Common situations: Checkbox is a styled div whose click target is an inner span, so synthetic clicks miss it; confirm dialog rendered in an overlay/iframe the code didn't account for; animation/transition swallowed the first click; XHS redesigning the dialog markup.

Related errors


AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05). Data as JSON: /api/errors/2ce94dd7436c0daa. Report an issue: GitHub.