Skip to main content
The AiToEarn browser extension reuses the platform sessions in the current browser so your web app can publish directly to Xiaohongshu, WeChat Channels, and Douyin. Users do not need to copy cookies.
You can first download and run the Open Platform demo. Switch to Browser extension at the top of the page, then follow this guide.

1. Install the extension

Follow the extension installation guide to install the AiToEarn browser extension.

2. Choose Authorize Only

Open the extension sidebar and select Authorize Only. Users do not need to sign in to an AiToEarn web account in this mode. Select Authorize Only in the extension
Authorize Only skips the AiToEarn web-account sign-in; it does not disable the Web API. After you authorize the web origin in the next step, that origin can call login(), publish(), and the helper methods listed on this page.

3. Configure an injectable domain

Under Allowed domains, enter the origin of the web page that will call the extension. For the local demo, enter:
For a deployed app, use its actual origin, such as https://demo.example.com/. Enter one HTTP or HTTPS URL per line.
Enter your demo or web-app origin, not a Xiaohongshu, WeChat Channels, or Douyin URL. The extension stores an origin match pattern, so http://localhost:5173/ becomes http://localhost:5173/*. Only add origins you trust.
Select Confirm and authorize, then refresh the web page so the extension can inject window.AIToEarnPlugin. Configure the demo origin as an allowed injectable domain

4. Detect the extension and read the platform account

Check the global object, version, and permissions before reading the platform session from the current browser:
login(platform) means “get the sign-in information for this publishing platform.” It does not sign in to AiToEarn or open a platform login form. The user must already be signed in to the target platform in the same browser. The Promise rejects if the platform session is missing or expired.
The raw login() response contains loginCookie. This is sensitive data. Do not display, log, persist, or send it to a third party. If you only need to show the account, immediately map the response to a summary containing fields such as nickname, avatar, and UID, as shown above.

5. Publish content

The following example publishes a local video to Xiaohongshu and receives download, upload, and publishing progress:
video, cover, and images accept either browser File objects or accessible HTTP/HTTPS URLs. Image-post example:
The extension downloads URL-based media first. Make sure each URL is directly accessible, has not expired, and can be fetched by the extension. Do not pass local paths, private-network addresses, or URLs that require an authenticated page session.

Methods available in Authorize Only mode

After an injectable origin is configured, the following Web APIs are available in Authorize Only mode:

Basic method parameters and responses

checkPermission()

This method takes no arguments and returns:

getVersion()

This method takes no arguments and returns:

login(platform)

platform must be xhs, wxSph, or douyin. A successful call returns: The Promise rejects with an Error on failure. Some errors also include code and errorCode.

publish() parameters

Call signature:
params fields: LocationInfo has the following shape:
Xiaohongshu declarations can be supplied in platformConfig:

Platform differences

Platform rules may change. Show validation and publishing errors returned by the extension to the user instead of silently ignoring them.

Publishing progress callback

onProgress receives a ProgressEvent on each update: Stage-specific data:

Publishing response

publish() resolves to a PublishResult: Communication failures, timeouts, and some platform errors can reject the Promise directly. Handle both the result and catch:

Location and WeChat Channels helpers

Map the selected platform item to the top-level location field in publish(). For WeChat Channels, map the complete location item to platformConfig.wxSph.poiInfo when you need platform-specific fields such as poiCheckSum.

WeChat Channels activities and work URLs

Pass the selected result from wxSphSearchActivity() to platformConfig.wxSph.event. If WeChat Channels does not immediately return a work URL, use fields such as mediaMd5sum from platformData to start link polling. platformData is platform-specific, so confirm that each field exists before reading it.

Interaction methods

These methods are also available in Authorize Only mode, but they are not required for publishing:
Automated interactions may encounter verification or platform risk controls. If needHumanAssist is true, stop automatic retries and show verificationReason so the user can take over.

Troubleshooting

  • window.AIToEarnPlugin is missing: confirm that the extension is installed and the current origin is in Allowed domains, then refresh the page. If the extension is not installed, link users to https://docs.aitoearn.ai/en/use/plugin-publish.
  • login() is unavailable after Authorize Only: use the latest extension version that includes login() in the allowlist, and refresh the page after changing the domain configuration.
  • Account check failed: sign in to the target platform in the same browser, then call login(platform) again.
  • Publishing failed: show the rejected Promise, failReason, and errorCode, then check the media URL, platform session, content type, and cover requirements.
  • No work URL is returned immediately: persist the workId first. For WeChat Channels, start link polling with wxSphStartLinkPolling() as described above.
Last modified on August 12, 2026