Build Publishing Script
Currently, all platforms adopt page operation methods for implementation, mainly including the following key parts:
Basic Architecture
Each platform's dynamic publishing functionality needs to implement the following interface:
Implementation Pattern
All platforms follow similar implementation patterns:
1. Register Platform Information to infos
Each platform needs to be registered in infos
, then initialized through the information in infos
.
For example, Bilibili dynamic publishing platform information is as follows:
Where accountKey is the key to get account information, used to retrieve account information. For details, see src/sync/account.ts
and the src/sync/account
folder.
2. Content Processing
2.1 Title
Get the input box or other input area, then fill in content. Consider directly using textContent
or innerHTML
for filling, or using copy-paste events and other methods.
2.2 Content
Get the input box or other input area, then fill in content. Consider directly using textContent
or innerHTML
for filling, or using copy-paste events and other methods.
2.3 Upload Images/Videos etc.
After finding the file input Input, use fetch to download images/videos etc., then use DataTransfer to simulate file upload.
3. Auto Publish (Optional)
Development Suggestions
- Learn to use
devtools
, use element inspection to get element information. - Learn the use of various
events
, such asinput
,change
,click
, etc. - Learn the use of
browser APIs
, such asfetch
,DataTransfer
,ClipboardEvent
, etc. For more information, refer to MDN - When encountering problems, try using
console.log
to output information first, then judge the problem based on the information.