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

Skip to content

Conversation

@timerring
Copy link
Member

Summary

Add Zhihu (知乎) platform support for article synchronization.

Changes

Browser Extension

  • Implemented Zhihu-specific sync logic in syncToPlatform() using the "Import Document" feature
  • The extension navigates to https://zhuanlan.zhihu.com/write, fills the title, and uploads the markdown content as a .md file

Implementation Details

Instead of direct content pasting (which fails on Zhihu), this PR uses Zhihu's native "Import Document" feature:

  1. Open Zhihu writing page
  2. Fill article title
  3. Click "导入" (Import) button → Click "导入文档" (Import Document) submenu
  4. Programmatically create and upload a .md file using the File API

Technical Notes

  • Button selectors use innerText.includes() to handle zero-width characters in Zhihu's UI
  • File is created in memory using new File() API with text/plain MIME type
  • Both change event and drag-drop fallback are triggered for compatibility

Testing

  1. Install the browser extension from cose/ directory
  2. Open the editor and select Zhihu for sync
  3. Verify the article title and content are imported correctly

@timerring timerring self-assigned this Dec 16, 2025
@timerring timerring added the enhancement New feature or request label Dec 16, 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 linked an issue Dec 16, 2025 that may be closed by this pull request
@timerring timerring merged commit ff8d6f9 into main Dec 16, 2025
@timerring timerring deleted the dev branch December 16, 2025 09:18
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.

Feature Request: Add Zhihu 知乎 Platform Support

2 participants