Content Publishing Principle
Publishing Function
In the src/components/Sync folder, there are publishing components corresponding to different platforms, such as DynamicTab, ArticleTab, VideoTab, etc.
After they organize the information needed for publishing, i.e., data of type SyncData, they will call the funcPublish function in the src/options/index.tsx file to create tabs and inject scripts.
Creating Tabs
In the previous section, we saw that the funcPublish function calls the createTabsForPlatforms function to create tabs, and then calls the injectScriptsToTabs function to inject scripts. These two functions are in the src/sync/common.ts file.
The principle is to use the chrome.tabs and chrome.scripting APIs to create tabs and inject scripts.
Injecting Scripts
In the injectScriptsToTabs function, we add listeners for each tab. When the tab finishes loading, it calls the getDefaultPlatformInfo function to get platform information and inject scripts.