Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@timerring
Copy link
Member

Summary

Add Toutiao/Jinritoutiao (今日头条) platform support for article synchronization.

Changes

  • Added Toutiao platform configuration in PLATFORMS array
  • Implemented login detection using Toutiao's media info API
  • Added content filling logic for Toutiao's rich text editor

Implementation Details

Login Detection:

  • Uses https://mp.toutiao.com/mp/agw/media/get_media_info API endpoint
  • Parses response.data.media.display_name for username
  • Parses response.data.media.https_avatar_url for avatar
  • Handles text/plain content-type response (Toutiao returns JSON with text/plain header)

Content Filling:

  • Title: Uses textarea[placeholder*="标题"] selector with React-compatible value setter (nativeInputValueSetter)
  • Content: Fills into ProseMirror/contenteditable editor with HTML content

Technical Notes

  • Toutiao API returns JSON data but with content-type: text/plain, so the extension parses both application/json and text/plain responses
  • React state updates require using Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value').set to properly trigger re-renders
  • Both input and change events are dispatched for compatibility

Testing

  1. Install the browser extension from cose/ directory
  2. Log in to Toutiao at https://mp.toutiao.com
  3. Open the editor and verify Toutiao shows your account name
  4. Select Toutiao for sync and verify title/content are filled correctly

@timerring timerring self-assigned this Dec 17, 2025
@timerring timerring added the enhancement New feature or request label Dec 17, 2025
Copy link
Member Author

@timerring timerring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@timerring timerring merged commit 616881a into main Dec 17, 2025
@timerring timerring deleted the dev branch December 17, 2025 08:12
@timerring timerring linked an issue Dec 17, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add Toutiao 今日头条 platform support

2 participants