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 Jianshu (简书) platform in the COSE browser extension, enabling users to sync articles directly to Jianshu. This update includes a new modular platform configuration, API-based login detection with real user profile retrieval, proper note creation workflow with notebook selection, and native textarea-based content filling.
Changes
Browser Extension (cose/)
Platform Configuration:
src/platforms/jianshu.jsto encapsulate all Jianshu-specific logic (platform config, login detection, content filler).src/platforms/index.jsfor centralized platform management.https://*.jianshu.com/*) tomanifest.json.Login Detection:
GET https://www.jianshu.com/author/current_user.nickname: Actual usernameavatar: User avatar URLid: Unique user identifier{ loggedIn: true, username, avatar }when authenticated.{ loggedIn: false }.Note Creation Workflow:
/writerwithout proper note context causes editor failure.syncToPlatform():GET https://www.jianshu.com/author/notebooksto fetch user's notebook listPOST https://www.jianshu.com/author/notesto create a new note withnotebook_idand initialtitle{"id": 123456789}https://www.jianshu.com/writer#/notebooks/{notebookId}/notes/{noteId}Content Filler:
fillJianshuContent()supporting Jianshu's native Markdown editor.input._24i7uorinput[class*="title"], useHTMLInputElement.prototype.valuesetter#arthur-editorortextarea._3swFR, useHTMLTextAreaElement.prototype.valuesetterinput,change,blur) to trigger React state updateselement.value = xassignment doesn't trigger React's controlled component updates. Using the native setter with proper event dispatching ensures the editor recognizes the content change.Web Application (apps/web/)
Login URL Integration:
https://www.jianshu.com/sign_in) toPostInfo.vuefor the "Login" link functionality.inject.jsfor frontend display.Technical Details
Notebook-Based Architecture:
React Controlled Input Handling:
element.value = x) doesn't work because React doesn't detect the change.Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').setand call it directly, then dispatch synthetic events to notify React.Editor Selectors:
input._24i7u(primary) orinput[class*="title"](fallback)#arthur-editor(primary) ortextarea._3swFR(fallback)Modular Architecture:
jianshu.js.Testing
Logged-Out Test:
Logged-In Test:
Sync Test:
https://www.jianshu.com/writer#/notebooks/{notebookId}/notes/{noteId}.Error Handling Test:
No Notebook Test: