feat: Add platform adapters for various content publishing platforms

- Implemented Dongchedi adapter for user detection and publishing.
- Implemented Jianshu adapter for user detection and publishing.
- Implemented Juejin adapter for user detection and publishing.
- Implemented Qiehao adapter for user detection and publishing.
- Implemented Smzdm adapter for user detection and publishing.
- Implemented Sohuhao adapter for user detection and publishing.
- Implemented Toutiaohao adapter for user detection and publishing.
- Implemented Wangyihao adapter for user detection and publishing.
- Implemented Weixin Gzh adapter for user detection and publishing.
- Implemented Zol adapter for user detection and publishing.
- Added documentation for manual testing of media publishing.
This commit is contained in:
2026-04-03 17:48:30 +08:00
parent 32d6a462cd
commit 134dd063c3
33 changed files with 2722 additions and 457 deletions
+28 -1
View File
@@ -9,6 +9,20 @@ type PublisherRequestMessage = {
payload?: unknown;
};
type BackgroundSuccessResponse = {
ok: true;
data: unknown;
};
type BackgroundErrorResponse = {
ok: false;
error?: string;
};
function isBackgroundResponse(value: unknown): value is BackgroundSuccessResponse | BackgroundErrorResponse {
return typeof value === "object" && value !== null && "ok" in value;
}
export default defineContentScript({
matches: ["http://*/*", "https://*/*"],
main() {
@@ -23,12 +37,25 @@ export default defineContentScript({
const { requestId, action, payload } = event.data;
try {
const data = await browser.runtime.sendMessage({
const response = await browser.runtime.sendMessage({
type: "geo.publisher.request",
action,
payload,
});
const data = isBackgroundResponse(response)
? (() => {
if (!response.ok) {
throw new Error(response.error || "publisher_plugin_unknown_error");
}
return response.data;
})()
: response;
if (typeof data === "undefined") {
throw new Error("publisher_plugin_empty_response");
}
window.postMessage(
{
source: "geo-extension",