yikart/AiToEarn · error · Error

插件未安装或未就绪

Error message

插件未安装或未就绪

What it means

The Xiaohongshu (xhs) interaction adapter's private checkPlugin() throws '插件未安装或未就绪' when window.AIToEarnPlugin is missing. likeWork, commentWork and favoriteWork all funnel through this guard because their DOM automation requires the extension's injected bridge on xiaohongshu.com.

Source

Thrown at project/aitoearn-web/src/store/plugin/plats/xhs/index.ts:41

  SubCommentListParams,
} from '../types'
import type { XhsBaseResponse, XhsCommentResponse } from './types'
import { PlatType } from '@/app/config/platConfig'
import { getCommentList, getSubCommentList } from './comment'
import { getHomeFeedList, homeFeedCursor } from './homeFeed'

/**
 * 小红书平台交互类
 */
class XhsPlatformInteraction implements IPlatformInteraction {
  readonly platformType = PlatType.Xhs

  /**
   * 检查插件是否可用
   */
  private checkPlugin(): void {
    if (!window.AIToEarnPlugin) {
      throw new Error('插件未安装或未就绪')
    }
  }

  /**
   * 重置首页列表游标缓存
   * 用于刷新列表时清除缓存
   */
  resetHomeFeedCursor(): void {
    homeFeedCursor.reset()
  }

  /**
   * 点赞/取消点赞作品
   */
  async likeWork(workId: string, isLike: boolean): Promise<LikeResult> {
    this.checkPlugin()

    if (window.AIToEarnPlugin!.unifiedInteraction) {

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Install/enable the Aitoearn extension and reload the xiaohongshu.com tab to re-inject the content script.
  2. Pre-check `!!window.AIToEarnPlugin` before calling actions and show an install/ready prompt instead of throwing.
  3. Gate the interaction UI on the plugin store's Status.READY value rather than calling blindly.
  4. Confirm extension site-access includes xiaohongshu.com and incognito access if applicable.

Example fix

// before
await xhsPlugin.likeWork(workId)

// after
if (!window.AIToEarnPlugin)
  return promptInstallPlugin()
await xhsPlugin.likeWork(workId)
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof window === 'undefined' || !window.AIToEarnPlugin) {
  showPluginInstallGuide('xhs')
  return
}

Type guard

function hasXhsPlugin(w: Window | undefined): w is Window & { AIToEarnPlugin: NonNullable<Window['AIToEarnPlugin']> } {
  return !!w && !!(w as Window).AIToEarnPlugin
}

Try / catch

try {
  await xhsPlugin.favoriteWork(workId)
}
catch (e) {
  if (e.message === '插件未安装或未就绪') {
    promptInstallOrReload()
    return
  }
  throw e
}

Prevention

When it happens

Trigger: Invoking any xhs interaction method while the Aitoearn extension is absent, disabled, not injected on the current tab, or the page is opened where extensions can't run (SSR, incognito without permission).

Common situations: User visits xiaohongshu.com without the extension; extension auto-updated requiring page reload; content-script injection blocked by site access settings; extension crashed after update.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/315ae672e1d057c7. Report an issue: GitHub.