yikart/AiToEarn · error · Error

插件未安装或未就绪

Error message

插件未安装或未就绪

What it means

The Douyin interaction adapter's private checkPlugin() guard throws '插件未安装或未就绪' when `window.AIToEarnPlugin` is undefined. All Douyin plugin actions (likeWork, commentWork, favoriteWork, sendDirectMessage) call it first because every DOM automation depends on the content script injected by the Aitoearn browser extension.

Source

Thrown at project/aitoearn-web/src/store/plugin/plats/douyin/index.ts:48

  SubCommentListParams,
} from '../types'
import type { DouyinDirectMessageResponse, DouyinInteractionResponse } from './types'
import { PlatType } from '@/app/config/platConfig'
import { getHomeFeedList, homeFeedCursor } from './homeFeed'
import { getWorkDetail, getWorkDetailFromListItem } from './workDetail'

/**
 * 抖音平台交互类
 */
class DouyinPlatformInteraction implements IPlatformInteraction {
  readonly platformType = PlatType.Douyin

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

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

  /**
   * 点赞/取消点赞作品(自动化方案)
   * 使用自动化方案避免 API 风控
   * @param workId 作品ID
   * @param isLike true=点赞,false=取消点赞
   */
  async likeWork(workId: string, isLike: boolean): Promise<LikeResult> {

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Install/enable the Aitoearn browser extension and reload the douyin.com tab so the content script injects window.AIToEarnPlugin.
  2. Before calling actions, check `typeof window !== 'undefined' && !!window.AIToEarnPlugin` and prompt the user with an install guide instead of letting the error throw.
  3. Check the plugin status store (Status.NOT_INSTALLED / READY) and gate interaction buttons on READY state.
  4. Verify incognito/site access permissions for the extension on douyin.com (chrome://extensions → site access).

Example fix

// before
await pluginManager.get('douyin').likeWork(params)

// after
if (!window.AIToEarnPlugin) {
  showInstallPluginGuide()
  return
}
await pluginManager.get('douyin').likeWork(params)
Defensive patterns

Strategy: type-guard

Validate before calling

const isPluginAvailable = () =>
  typeof window !== 'undefined' && !!window.AIToEarnPlugin
if (!isPluginAvailable()) {
  showPluginInstallGuide()
  return
}

Type guard

function hasDouyinPlugin(w: Window): w is Window & { AIToEarnPlugin: NonNullable<Window['AIToEarnPlugin']> } {
  return typeof w.AIToEarnPlugin !== 'undefined'
}

Try / catch

try {
  await pluginManager.get('douyin').likeWork(params)
}
catch (e) {
  if (e.message === '插件未安装或未就绪') {
    openPluginInstallDialog()
    return
  }
  throw e
}

Prevention

When it happens

Trigger: Calling any Douyin interaction method (like, comment, favorite, DM) in a page where the Aitoearn browser extension is not installed, disabled, not yet injected its content script, or running in an environment without the plugin (SSR/non-browser window).

Common situations: User browses douyin.com without the extension installed; extension just updated/disabled and page not reloaded; content script failed to inject on the tab; accessing the page in incognito where extensions are blocked.

Related errors


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