feat: baijiahao platform sync #1221
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add support for Baijiahao (百家号) platform in the COSE browser extension, enabling users to sync articles directly to Baijiahao. This update includes a new modular platform configuration, API-based login detection with real user profile retrieval, and clipboard-based content filling that preserves original styling (same approach as WeChat Official Account).
Changes
Browser Extension (cose/)
Platform Configuration:
https://pic.rmb.bdstatic.com/10e1e2b43c35577e1315f0f6aad6ba24.vnd.microsoft.icon).src/platforms/baijiahao.jsto encapsulate all Baijiahao-specific logic (platform config, login detection).src/platforms/index.jsfor centralized platform management.https://*.baijiahao.baidu.com/*,https://baijiahao.baidu.com/*) tomanifest.json.Login Detection:
BDUSScookie andGET https://baijiahao.baidu.com/builder/app/appinfo.username: Actual username (e.g., "timerring")avatar: User avatar URL from Baidu CDN{ loggedIn: true, username, avatar }when authenticated.{ loggedIn: false }.Content Sync Workflow:
syncToPlatform():navigator.clipboard.read()https://baijiahao.baidu.com/builder/rc/edit?type=newsexecCommandClipboardEventinto UEditor iframeContent Filler:
background.js..client_components_titleInputdocument.execCommand('insertText')for reliable text insertionClipboardEventwithDataTransfercontaining HTML contentWeb Application (apps/web/)
Platform Integration:
inject.jsfor frontend display.Technical Details
UEditor Integration:
window.UE_V2.instants.ueditorInstant0but clipboard paste is more reliable for styled content.Cross-Frame Content Injection:
javascript:void()src with dynamically written content.Clipboard HTML Preservation:
ClipboardEventwithDataTransfer.setData('text/html', content)preserves all styling.API Authentication:
BDUSScookie for Baidu account authentication./builder/app/appinfoendpoint returns user info without requiring additional token headers.{ errno: 0, data: { user: { username, avatar, ... } } }Modular Architecture:
baijiahao.js.background.jsalongside WeChat for shared clipboard logic.Testing
Installation
Logged-Out Test:
https://baijiahao.baidu.com/).Logged-In Test:
Sync Test:
https://baijiahao.baidu.com/builder/rc/edit?type=news.Files Changed
src/platforms/baijiahao.js(new)src/platforms/index.jssrc/inject.jssrc/background.jsmanifest.json