Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

refactor(extension): migrate clipper UI to React and Tailwind

tianma-if76596f79e730
diff --git a/apps/extension/README.md b/apps/extension/README.md
index b726a06c..b5ac15df 100644
--- a/apps/extension/README.md
+++ b/apps/extension/README.md
@@ -27,6 +27,10 @@ The extension does not use a central relay service. The page content is sent dir
HN usage and verification limits are documented in [English](../../docs/browser-clipper-hacker-news.md) and [简体中文](../../docs/browser-clipper-hacker-news.zh-CN.md).
+## UI architecture
+
+Extension pages use React, shared shadcn/ui-style Button and Input components, and Tailwind CSS 4 with a neutral theme. The webpage feedback UI uses Sonner inside a Shadow DOM, bundled as a standalone classic script. Its stylesheet stays inside the shadow root; image readers and content extractors do not load React. Permission requests remain in click handlers.
+
## Localization
The extension uses the cross-browser `chrome.i18n` compatibility namespace. English is the fallback locale. Simplified Chinese, Japanese, and Polish are available for browsers whose UI language matches.
diff --git a/apps/extension/capture-bundle.test.mjs b/apps/extension/capture-bundle.test.mjs
index 490f4211..e4730af8 100644
--- a/apps/extension/capture-bundle.test.mjs
+++ b/apps/extension/capture-bundle.test.mjs
@@ -85,6 +85,13 @@ test("the injected page capture is a standalone classic script", async () => {
const platform = await readFile(join(outDir, "assets/capture-platform.js"), "utf8");
expect(() => new Script(platform)).not.toThrow();
expect(platform).toContain("pagePlatformRead");
+ const feedback = await readFile(join(outDir, "assets/clip-feedback.js"), "utf8");
+ expect(() => new Script(feedback)).not.toThrow();
+ expect(feedback).toContain("data-sonner-toaster");
+ // UI dependencies belong only to the feedback bundle, never image reading.
+ const image = await readFile(join(outDir, "assets/capture-image.js"), "utf8");
+ expect(() => new Script(image)).not.toThrow();
+ expect(image).not.toContain("data-sonner-toaster");
} finally {
await rm(outDir, { recursive: true, force: true });
}
diff --git a/apps/extension/image-save.html b/apps/extension/image-save.html
index 68da7042..e5f23eb9 100644
--- a/apps/extension/image-save.html
+++ b/apps/extension/image-save.html
@@ -3,19 +3,10 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title data-i18n="imageSaveWindowTitle">Save image to EdgeEver</title>
+ <title>Save image to EdgeEver</title>
</head>
<body>
- <main class="image-save-shell">
- <h1 data-i18n="imageSaveWindowTitle">Save image to EdgeEver</h1>
- <p class="hint" data-i18n="imagePermissionIntro">This page cannot read the image file. After you allow the site that hosts it, EdgeEver saves it as a new note in the clipper's default notebook. Only the image you chose is read.</p>
- <p id="host" class="hint"></p>
- <div class="image-save-actions">
- <button id="allow" type="button" disabled data-i18n="allowAndSaveImage">Allow and save</button>
- <button id="allow-all" class="secondary" type="button" disabled data-i18n="allowAllSitesAndSave">Allow all sites and save future images directly</button>
- </div>
- <p id="status" class="status" role="status"></p>
- </main>
- <script type="module" src="/src/image-save.ts"></script>
+ <div id="root"></div>
+ <script type="module" src="/src/ui/main.tsx"></script>
</body>
</html>
diff --git a/apps/extension/options.html b/apps/extension/options.html
index be3799b8..33f2d3e0 100644
--- a/apps/extension/options.html
+++ b/apps/extension/options.html
@@ -3,58 +3,10 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title data-i18n="optionsTitle">EdgeEver Web Clipper settings</title>
+ <title>EdgeEver Web Clipper settings</title>
</head>
<body>
- <main class="options-shell">
- <h1 data-i18n="extensionName">EdgeEver Web Clipper</h1>
- <p class="hint" data-i18n="optionsSubtitle">配置自托管 EdgeEver 实例连接与默认剪藏笔记本。</p>
- <form id="settings-form">
- <label>
- <span data-i18n="instanceAddress">EdgeEver instance URL</span>
- <input id="instance-url" type="url" placeholder="https://notes.example.com" required />
- </label>
- <label>
- API Token
- <input id="token" type="password" placeholder="Create one in EdgeEver settings" data-i18n-placeholder="tokenPlaceholder" required />
- </label>
- <label>
- <span data-i18n="defaultNotebook">Default notebook</span>
- <select id="notebook-id">
- <option value="" data-i18n="autoFirstNotebook">Use the first notebook automatically after connecting</option>
- </select>
- </label>
- <div class="actions">
- <button id="test" type="button" class="secondary" data-i18n="testConnection">Test connection</button>
- <button id="save" type="submit" data-i18n="saveSettings">Save settings</button>
- </div>
- <p id="status" class="status" role="status"></p>
- </form>
- <section class="diagnostics-panel" aria-labelledby="diagnostics-title">
- <h2 id="diagnostics-title" data-i18n="diagnosticsTitle">About &amp; diagnostics</h2>
- <p class="hint" data-i18n="diagnosticsDescription">View basic extension, browser, system, and connection information. API tokens are never included.</p>
- <dl class="diagnostics-list">
- <div><dt data-i18n="extensionVersion">Extension version</dt><dd id="extension-version">—</dd></div>
- <div><dt data-i18n="manifestVersion">Manifest version</dt><dd id="manifest-version">—</dd></div>
- <div><dt data-i18n="browserVersion">Browser</dt><dd id="browser-version">—</dd></div>
- <div><dt data-i18n="systemVersion">System</dt><dd id="system-version">—</dd></div>
- <div><dt data-i18n="extensionId">Extension ID</dt><dd id="extension-id">—</dd></div>
- <div><dt data-i18n="instanceOrigin">Instance origin</dt><dd id="instance-origin">—</dd></div>
- <div><dt data-i18n="instancePermission">Instance permission</dt><dd id="instance-permission">—</dd></div>
- </dl>
- <div class="diagnostics-actions">
- <button id="copy-diagnostics" type="button" class="secondary" data-i18n="copyDiagnostics">Copy diagnostics</button>
- <span id="copy-status" class="status" role="status"></span>
- </div>
- </section>
- <p class="about-links">
- <a href="https://github.com/tianma-if/edgeever" target="_blank" rel="noopener noreferrer" data-i18n="projectAndSource">GitHub project &amp; source</a>
- <span aria-hidden="true">·</span>
- <a href="https://github.com/tianma-if/edgeever/issues" target="_blank" rel="noopener noreferrer" data-i18n="reportIssue">Report an issue</a>
- <span aria-hidden="true">·</span>
- <a href="https://edgeever.org/privacy" target="_blank" rel="noopener noreferrer" data-i18n="privacyPolicy">Privacy policy</a>
- </p>
- </main>
- <script type="module" src="/src/options.ts"></script>
+ <div id="root"></div>
+ <script type="module" src="/src/ui/main.tsx"></script>
</body>
</html>
diff --git a/apps/extension/package.json b/apps/extension/package.json
index 7e57de3f..4058582b 100644
--- a/apps/extension/package.json
+++ b/apps/extension/package.json
@@ -15,6 +15,9 @@
"@mixmark-io/domino": "2.2.0",
"@mozilla/readability": "^0.6.0",
"marked": "^18.0.5",
+ "react": "~19.2.7",
+ "react-dom": "~19.2.7",
+ "sonner": "2.0.8",
"turndown": "^7.2.4"
},
"devDependencies": {
diff --git a/apps/extension/platform-save.test.mjs b/apps/extension/platform-save.test.mjs
index 9ecb393b..ae228ac8 100644
--- a/apps/extension/platform-save.test.mjs
+++ b/apps/extension/platform-save.test.mjs
@@ -93,7 +93,7 @@ const harness = (options = {}) => {
}
if (files?.[0] === "assets/capture-platform.js") runInContext(captureScript, pageContext);
else if (files?.[0] === "assets/capture.js") runInContext(pageCaptureScript, pageContext);
- else if (files?.[0] !== "assets/capture-image.js") throw new Error(`Unexpected generic fallback: ${files}`);
+ else if (!["assets/capture-image.js", "assets/clip-feedback.js"].includes(files?.[0])) throw new Error(`Unexpected generic fallback: ${files}`);
return [];
} },
action: { setBadgeBackgroundColor: async () => {}, setBadgeText: async () => {} },
diff --git a/apps/extension/popup.html b/apps/extension/popup.html
index 0bf51c71..da685448 100644
--- a/apps/extension/popup.html
+++ b/apps/extension/popup.html
@@ -3,39 +3,10 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title data-i18n="actionTitle">Save to EdgeEver</title>
+ <title>Save to EdgeEver</title>
</head>
<body>
- <main class="popup-shell">
- <header class="popup-header">
- <img src="/icons/icon-32.png" width="32" height="32" alt="" />
- <div>
- <h1>EdgeEver</h1>
- <p class="hint" data-i18n="webClipper">Web Clipper</p>
- </div>
- <div id="capture-context" class="popup-context" aria-live="polite">
- <svg class="capture-check" aria-hidden="true" viewBox="0 0 16 16" width="12" height="12">
- <path d="m3.5 8 3 3 6-6" />
- </svg>
- <span id="capture-mode" class="capture-mode" data-i18n="checkingPageCapture">识别中</span>
- </div>
- </header>
- <button id="save" class="save-button" type="button" disabled>
- <svg aria-hidden="true" viewBox="0 0 24 24" width="18" height="18">
- <path d="M5 4.75A1.75 1.75 0 0 1 6.75 3h8.836c.464 0 .91.184 1.238.513l1.663 1.663c.329.328.513.774.513 1.238v12.836A1.75 1.75 0 0 1 17.25 21H6.75A1.75 1.75 0 0 1 5 19.25V4.75Z" />
- <path d="M8 3v5h7V3M8 21v-7h8v7" />
- </svg>
- <span data-i18n="saveCurrentPage">Clip current page</span>
- </button>
- <p id="status" class="status" role="status"></p>
- <button id="settings" class="settings-button" type="button">
- <svg aria-hidden="true" viewBox="0 0 24 24" width="17" height="17">
- <path d="M12 15.25A3.25 3.25 0 1 0 12 8.75a3.25 3.25 0 0 0 0 6.5Z" />
- <path d="M19.4 15a1.7 1.7 0 0 0 .34 1.88l.06.06-2.86 2.86-.06-.06A1.7 1.7 0 0 0 15 19.4a1.7 1.7 0 0 0-1 .6 1.7 1.7 0 0 0-.4 1.1V21h-4v-.1A1.7 1.7 0 0 0 8.6 19.4a1.7 1.7 0 0 0-1.88.34l-.06.06L3.8 16.94l.06-.06A1.7 1.7 0 0 0 4.2 15a1.7 1.7 0 0 0-.6-1 1.7 1.7 0 0 0-1.1-.4H2.4v-4h.1A1.7 1.7 0 0 0 4.2 8.6a1.7 1.7 0 0 0-.34-1.88L3.8 6.66 6.66 3.8l.06.06A1.7 1.7 0 0 0 8.6 4.2a1.7 1.7 0 0 0 1-.6 1.7 1.7 0 0 0 .4-1.1v-.1h4v.1a1.7 1.7 0 0 0 1 1.7 1.7 1.7 0 0 0 1.88-.34l.06-.06 2.86 2.86-.06.06A1.7 1.7 0 0 0 19.4 8.6a1.7 1.7 0 0 0 .6 1 1.7 1.7 0 0 0 1.1.4h.1v4h-.1a1.7 1.7 0 0 0-1.7 1Z" />
- </svg>
- <span data-i18n="pluginSettings">Extension settings</span>
- </button>
- </main>
- <script type="module" src="/src/popup.ts"></script>
+ <div id="root"></div>
+ <script type="module" src="/src/ui/main.tsx"></script>
</body>
</html>
diff --git a/apps/extension/popup.test.mjs b/apps/extension/popup.test.mjs
index 5c71d836..0515c09d 100644
--- a/apps/extension/popup.test.mjs
+++ b/apps/extension/popup.test.mjs
@@ -1,67 +1,56 @@
import { expect, test } from "bun:test";
+import { captureCurrentPage } from "./src/popup";
-test("requests instance permission during the popup click user action", async () => {
- const previousChrome = globalThis.chrome;
- const previousDocument = globalThis.document;
- const listeners = new Map();
- const saveButton = {
- disabled: false,
- addEventListener: (event, listener) => listeners.set(`save:${event}`, listener),
- };
- const settingsButton = { addEventListener: () => {} };
- const status = { textContent: "", dataset: {} };
- const captureMode = { textContent:"" };
- let finishLoadingSettings;
+const settings = { instanceUrl: "https://example.com", token: "token", notebookId: "" };
+async function withChrome(overrides, run) {
+ const previous = globalThis.chrome;
+ globalThis.chrome = { i18n: { getMessage: key => key }, ...overrides };
+ try { await run(); } finally { globalThis.chrome = previous; }
+}
+
+test("popup requests instance permission synchronously within the click before capturing", async () => {
let insideClick = false;
- let permissionRequests = 0;
+ let resolvePermission;
let captures = 0;
-
- globalThis.document = {
- documentElement: { lang: "", dir: "" },
- querySelectorAll: () => [],
- querySelector: (selector) => ({ "#save": saveButton, "#settings": settingsButton, "#status": status, "#capture-mode":captureMode })[selector],
- };
- globalThis.chrome = {
- i18n: { getMessage: (key) => key, getUILanguage: () => "en" },
- storage: { local: { get: () => new Promise((resolve) => { finishLoadingSettings = resolve; }) } },
- permissions: {
- request: ({ origins }) => {
- expect(insideClick).toBe(true);
- expect(origins).toEqual(["https://example.com/*"]);
- permissionRequests += 1;
- return Promise.resolve(true);
- },
- },
- runtime: {
- sendMessage: async (message) => {
- if (message.type === 'getCurrentPageCaptureMode') return {kind:'platform',platform:'Threads'};
- expect(message).toEqual({ type: "captureCurrentPage" });
- captures += 1;
- return { ok: true };
- },
- },
- };
-
- try {
- await import("./src/popup.ts");
- expect(saveButton.disabled).toBe(true);
-
- finishLoadingSettings({ instanceUrl: "https://example.com", token: "token", notebookId: "" });
- await new Promise((resolve) => setTimeout(resolve, 0));
- expect(saveButton.disabled).toBe(false);
- expect(captureMode.textContent).toBe('pageCaptureAdapted');
-
+ await withChrome({
+ permissions: { request: ({ origins }) => {
+ expect(insideClick).toBe(true);
+ expect(origins).toEqual(["https://example.com/*"]);
+ return new Promise(resolve => { resolvePermission = resolve; });
+ } },
+ runtime: { sendMessage: async message => {
+ expect(message).toEqual({ type: "captureCurrentPage" }); captures++;
+ return { ok: true, message: "saved" };
+ } },
+ }, async () => {
insideClick = true;
- const click = listeners.get("save:click")();
+ const saving = captureCurrentPage(settings);
insideClick = false;
- await click;
-
- expect(permissionRequests).toBe(1);
+ expect(captures).toBe(0);
+ resolvePermission(true);
+ expect(await saving).toBe("saved");
expect(captures).toBe(1);
- expect(status.textContent).toBe("savedToEdgeEver");
- expect(saveButton.disabled).toBe(false);
- } finally {
- globalThis.chrome = previousChrome;
- globalThis.document = previousDocument;
- }
+ });
+});
+
+test("denied permission prevents popup capture", async () => {
+ let captures = 0;
+ await withChrome({ permissions: { request: async () => false }, runtime: { sendMessage: async () => { captures++; } } }, async () => {
+ await expect(captureCurrentPage(settings)).rejects.toThrow("instancePermissionRequired");
+ expect(captures).toBe(0);
+ });
+});
+
+test("missing configuration never requests permissions or capture", async () => {
+ await withChrome({}, async () => {
+ await expect(captureCurrentPage({ ...settings, token: "" })).rejects.toThrow("completePluginConfiguration");
+ });
+});
+
+test("popup retains background failures and localized success fallback", async () => {
+ await withChrome({ permissions: { request: async () => true }, runtime: { sendMessage: async () => ({ ok: false, message: "Unreadable page" }) } }, async () => {
+ await expect(captureCurrentPage(settings)).rejects.toThrow("Unreadable page");
+ chrome.runtime.sendMessage = async () => ({ ok: true });
+ expect(await captureCurrentPage(settings)).toBe("savedToEdgeEver");
+ });
});
diff --git a/apps/extension/public/_locales/en/messages.json b/apps/extension/public/_locales/en/messages.json
index 74d32ad6..640779da 100644
--- a/apps/extension/public/_locales/en/messages.json
+++ b/apps/extension/public/_locales/en/messages.json
@@ -35,9 +35,6 @@
"optionsTitle": {
"message": "EdgeEver Web Clipper settings"
},
- "optionsSubtitle": {
- "message": "Configure your self-hosted EdgeEver instance connection and default notebook."
- },
"diagnosticsTitle": {
"message": "About & diagnostics"
},
@@ -650,5 +647,65 @@
},
"saveSubstackNoteToEdgeEver": {
"message": "Save Substack Note to EdgeEver"
+ },
+ "adaptedPlatformsTitle": {
+ "message": "Deeply adapted platforms"
+ },
+ "platformXiaohongshu": {
+ "message": "Xiaohongshu"
+ },
+ "platformBilibili": {
+ "message": "Bilibili"
+ },
+ "platformPosts": {
+ "message": "Posts"
+ },
+ "platformNotes": {
+ "message": "Notes & images"
+ },
+ "platformAnswersArticles": {
+ "message": "Answers & articles"
+ },
+ "platformRepositories": {
+ "message": "Repository details"
+ },
+ "platformCaptionsImages": {
+ "message": "Captions & images"
+ },
+ "platformMainPosts": {
+ "message": "Main posts"
+ },
+ "platformTopics": {
+ "message": "Topics & supplements"
+ },
+ "platformShowNotes": {
+ "message": "Episode Show Notes"
+ },
+ "platformArticles": {
+ "message": "Articles"
+ },
+ "platformArticlesNotes": {
+ "message": "Articles & Notes"
+ },
+ "platformVideoCaptions": {
+ "message": "Video captions"
+ },
+ "viewDiagnostics": {
+ "message": "View diagnostics"
+ },
+ "socialPlatformsTitle": {
+ "message": "Social posts"
+ },
+ "readingPlatformsTitle": {
+ "message": "Articles & communities"
+ },
+ "mediaPlatformsTitle": {
+ "message": "Videos & podcasts"
+ },
+ "closeNotification": {
+ "message": "Close notification"
+ },
+ "clipNotifications": {
+ "message": "Clipping notifications"
}
}
diff --git a/apps/extension/public/_locales/ja/messages.json b/apps/extension/public/_locales/ja/messages.json
index 526197a8..7b5a96de 100644
--- a/apps/extension/public/_locales/ja/messages.json
+++ b/apps/extension/public/_locales/ja/messages.json
@@ -35,9 +35,6 @@
"optionsTitle": {
"message": "EdgeEver Web Clipper の設定"
},
- "optionsSubtitle": {
- "message": "EdgeEver インスタンスへの接続と既定のノートブックを設定します。"
- },
"diagnosticsTitle": {
"message": "情報と診断"
},
@@ -650,5 +647,65 @@
},
"saveSubstackNoteToEdgeEver": {
"message": "Substack Note を EdgeEver に保存"
+ },
+ "adaptedPlatformsTitle": {
+ "message": "専用対応プラットフォーム"
+ },
+ "platformXiaohongshu": {
+ "message": "小紅書"
+ },
+ "platformBilibili": {
+ "message": "Bilibili"
+ },
+ "platformPosts": {
+ "message": "投稿"
+ },
+ "platformNotes": {
+ "message": "ノート・画像"
+ },
+ "platformAnswersArticles": {
+ "message": "回答・記事"
+ },
+ "platformRepositories": {
+ "message": "リポジトリ情報"
+ },
+ "platformCaptionsImages": {
+ "message": "キャプション・画像"
+ },
+ "platformMainPosts": {
+ "message": "メイン投稿"
+ },
+ "platformTopics": {
+ "message": "トピック・追記"
+ },
+ "platformShowNotes": {
+ "message": "エピソードの Show Notes"
+ },
+ "platformArticles": {
+ "message": "記事"
+ },
+ "platformArticlesNotes": {
+ "message": "記事・Notes"
+ },
+ "platformVideoCaptions": {
+ "message": "動画の字幕"
+ },
+ "viewDiagnostics": {
+ "message": "診断情報を表示"
+ },
+ "socialPlatformsTitle": {
+ "message": "ソーシャル投稿"
+ },
+ "readingPlatformsTitle": {
+ "message": "記事・コミュニティ"
+ },
+ "mediaPlatformsTitle": {
+ "message": "動画・ポッドキャスト"
+ },
+ "closeNotification": {
+ "message": "通知を閉じる"
+ },
+ "clipNotifications": {
+ "message": "クリップの通知"
}
}
diff --git a/apps/extension/public/_locales/pl/messages.json b/apps/extension/public/_locales/pl/messages.json
index 7e23f182..aaa73dff 100644
--- a/apps/extension/public/_locales/pl/messages.json
+++ b/apps/extension/public/_locales/pl/messages.json
@@ -35,9 +35,6 @@
"optionsTitle": {
"message": "Ustawienia EdgeEver Web Clipper"
},
- "optionsSubtitle": {
- "message": "Skonfiguruj połączenie z samodzielnie hostowaną instancją EdgeEver i domyślny notatnik."
- },
"diagnosticsTitle": {
"message": "Informacje i diagnostyka"
},
@@ -650,5 +647,65 @@
},
"saveSubstackNoteToEdgeEver": {
"message": "Zapisz notatkę Substack w EdgeEver"
+ },
+ "adaptedPlatformsTitle": {
+ "message": "Platformy z dedykowaną obsługą"
+ },
+ "platformXiaohongshu": {
+ "message": "Xiaohongshu"
+ },
+ "platformBilibili": {
+ "message": "Bilibili"
+ },
+ "platformPosts": {
+ "message": "Posty"
+ },
+ "platformNotes": {
+ "message": "Notatki i zdjęcia"
+ },
+ "platformAnswersArticles": {
+ "message": "Odpowiedzi i artykuły"
+ },
+ "platformRepositories": {
+ "message": "Informacje o repozytorium"
+ },
+ "platformCaptionsImages": {
+ "message": "Podpisy i zdjęcia"
+ },
+ "platformMainPosts": {
+ "message": "Główne posty"
+ },
+ "platformTopics": {
+ "message": "Tematy i uzupełnienia"
+ },
+ "platformShowNotes": {
+ "message": "Show Notes odcinka"
+ },
+ "platformArticles": {
+ "message": "Artykuły"
+ },
+ "platformArticlesNotes": {
+ "message": "Artykuły i Notes"
+ },
+ "platformVideoCaptions": {
+ "message": "Napisy do filmów"
+ },
+ "viewDiagnostics": {
+ "message": "Pokaż diagnostykę"
+ },
+ "socialPlatformsTitle": {
+ "message": "Posty społecznościowe"
+ },
+ "readingPlatformsTitle": {
+ "message": "Artykuły i społeczności"
+ },
+ "mediaPlatformsTitle": {
+ "message": "Filmy i podcasty"
+ },
+ "closeNotification": {
+ "message": "Zamknij powiadomienie"
+ },
+ "clipNotifications": {
+ "message": "Powiadomienia o zapisywaniu"
}
}
diff --git a/apps/extension/public/_locales/zh_CN/messages.json b/apps/extension/public/_locales/zh_CN/messages.json
index 836c66c1..2f69cdcc 100644
--- a/apps/extension/public/_locales/zh_CN/messages.json
+++ b/apps/extension/public/_locales/zh_CN/messages.json
@@ -35,9 +35,6 @@
"optionsTitle": {
"message": "EdgeEver Web Clipper 设置"
},
- "optionsSubtitle": {
- "message": "配置自托管 EdgeEver 实例连接与默认剪藏笔记本。"
- },
"diagnosticsTitle": {
"message": "关于与诊断信息"
},
@@ -650,5 +647,65 @@
},
"saveSubstackNoteToEdgeEver": {
"message": "保存 Substack 短帖到 EdgeEver"
+ },
+ "adaptedPlatformsTitle": {
+ "message": "深度适配平台"
+ },
+ "platformXiaohongshu": {
+ "message": "小红书"
+ },
+ "platformBilibili": {
+ "message": "哔哩哔哩"
+ },
+ "platformPosts": {
+ "message": "帖子"
+ },
+ "platformNotes": {
+ "message": "笔记与图集"
+ },
+ "platformAnswersArticles": {
+ "message": "回答与文章"
+ },
+ "platformRepositories": {
+ "message": "仓库信息"
+ },
+ "platformCaptionsImages": {
+ "message": "配文与图集"
+ },
+ "platformMainPosts": {
+ "message": "主帖"
+ },
+ "platformTopics": {
+ "message": "主题与补充"
+ },
+ "platformShowNotes": {
+ "message": "单集 Show Notes"
+ },
+ "platformArticles": {
+ "message": "文章"
+ },
+ "platformArticlesNotes": {
+ "message": "文章与 Notes"
+ },
+ "platformVideoCaptions": {
+ "message": "视频字幕"
+ },
+ "viewDiagnostics": {
+ "message": "查看诊断信息"
+ },
+ "socialPlatformsTitle": {
+ "message": "社交动态"
+ },
+ "readingPlatformsTitle": {
+ "message": "文章与社区"
+ },
+ "mediaPlatformsTitle": {
+ "message": "视频与播客"
+ },
+ "closeNotification": {
+ "message": "关闭提示"
+ },
+ "clipNotifications": {
+ "message": "剪藏提示"
}
}
diff --git a/apps/extension/public/platform-icons/SOURCES.txt b/apps/extension/public/platform-icons/SOURCES.txt
new file mode 100644
index 00000000..d60a61bd
--- /dev/null
+++ b/apps/extension/public/platform-icons/SOURCES.txt
@@ -0,0 +1,4 @@
+Brand icons: Simple Icons (CC0-1.0), https://github.com/simple-icons/simple-icons
+SVGs from develop; LinkedIn from 11.15.0; Hacker News uses Y Combinator.
+Colors added for display. Brand trademarks remain with their owners.
+Xiaoyuzhou favicon: https://www.xiaoyuzhoufm.com/favicon-32x32.png
diff --git a/apps/extension/public/platform-icons/bilibili.svg b/apps/extension/public/platform-icons/bilibili.svg
new file mode 100644
index 00000000..197279f3
--- /dev/null
+++ b/apps/extension/public/platform-icons/bilibili.svg
@@ -0,0 +1 @@
+<svg fill="#00a1d6" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Bilibili</title><path d="M17.813 4.653h.854c1.51.054 2.769.578 3.773 1.574 1.004.995 1.524 2.249 1.56 3.76v7.36c-.036 1.51-.556 2.769-1.56 3.773s-2.262 1.524-3.773 1.56H5.333c-1.51-.036-2.769-.556-3.773-1.56S.036 18.858 0 17.347v-7.36c.036-1.511.556-2.765 1.56-3.76 1.004-.996 2.262-1.52 3.773-1.574h.774l-1.174-1.12a1.234 1.234 0 0 1-.373-.906c0-.356.124-.658.373-.907l.027-.027c.267-.249.573-.373.92-.373.347 0 .653.124.92.373L9.653 4.44c.071.071.134.142.187.213h4.267a.836.836 0 0 1 .16-.213l2.853-2.747c.267-.249.573-.373.92-.373.347 0 .662.151.929.4.267.249.391.551.391.907 0 .355-.124.657-.373.906zM5.333 7.24c-.746.018-1.373.276-1.88.773-.506.498-.769 1.13-.786 1.894v7.52c.017.764.28 1.395.786 1.893.507.498 1.134.756 1.88.773h13.334c.746-.017 1.373-.275 1.88-.773.506-.498.769-1.129.786-1.893v-7.52c-.017-.765-.28-1.396-.786-1.894-.507-.497-1.134-.755-1.88-.773zM8 11.107c.373 0 .684.124.933.373.25.249.383.569.4.96v1.173c-.017.391-.15.711-.4.96-.249.25-.56.374-.933.374s-.684-.125-.933-.374c-.25-.249-.383-.569-.4-.96V12.44c0-.373.129-.689.386-.947.258-.257.574-.386.947-.386zm8 0c.373 0 .684.124.933.373.25.249.383.569.4.96v1.173c-.017.391-.15.711-.4.96-.249.25-.56.374-.933.374s-.684-.125-.933-.374c-.25-.249-.383-.569-.4-.96V12.44c.017-.391.15-.711.4-.96.249-.249.56-.373.933-.373Z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/bluesky.svg b/apps/extension/public/platform-icons/bluesky.svg
new file mode 100644
index 00000000..07f9c537
--- /dev/null
+++ b/apps/extension/public/platform-icons/bluesky.svg
@@ -0,0 +1 @@
+<svg fill="#0285ff" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Bluesky</title><path d="M5.202 2.857C7.954 4.922 10.913 9.11 12 11.358c1.087-2.247 4.046-6.436 6.798-8.501C20.783 1.366 24 .213 24 3.883c0 .732-.42 6.156-.667 7.037-.856 3.061-3.978 3.842-6.755 3.37 4.854.826 6.089 3.562 3.422 6.299-5.065 5.196-7.28-1.304-7.847-2.97-.104-.305-.152-.448-.153-.327 0-.121-.05.022-.153.327-.568 1.666-2.782 8.166-7.847 2.97-2.667-2.737-1.432-5.473 3.422-6.3-2.777.473-5.899-.308-6.755-3.369C.42 10.04 0 4.615 0 3.883c0-3.67 3.217-2.517 5.202-1.026"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/facebook.svg b/apps/extension/public/platform-icons/facebook.svg
new file mode 100644
index 00000000..8db95076
--- /dev/null
+++ b/apps/extension/public/platform-icons/facebook.svg
@@ -0,0 +1 @@
+<svg fill="#0866ff" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Facebook</title><path d="M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/github.svg b/apps/extension/public/platform-icons/github.svg
new file mode 100644
index 00000000..81920ca3
--- /dev/null
+++ b/apps/extension/public/platform-icons/github.svg
@@ -0,0 +1 @@
+<svg fill="#181717" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/hackernews.svg b/apps/extension/public/platform-icons/hackernews.svg
new file mode 100644
index 00000000..b69a2121
--- /dev/null
+++ b/apps/extension/public/platform-icons/hackernews.svg
@@ -0,0 +1 @@
+<svg fill="#f60" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Y Combinator</title><path d="M0 24V0h24v24H0zM6.951 5.896l4.112 7.708v5.064h1.583v-4.972l4.148-7.799h-1.749l-2.457 4.875c-.372.745-.688 1.434-.688 1.434s-.297-.708-.651-1.434L8.831 5.896h-1.88z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/instagram.svg b/apps/extension/public/platform-icons/instagram.svg
new file mode 100644
index 00000000..a8b97b67
--- /dev/null
+++ b/apps/extension/public/platform-icons/instagram.svg
@@ -0,0 +1 @@
+<svg fill="#e4405f" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Instagram</title><path d="M7.0301.084c-1.2768.0602-2.1487.264-2.911.5634-.7888.3075-1.4575.72-2.1228 1.3877-.6652.6677-1.075 1.3368-1.3802 2.127-.2954.7638-.4956 1.6365-.552 2.914-.0564 1.2775-.0689 1.6882-.0626 4.947.0062 3.2586.0206 3.6671.0825 4.9473.061 1.2765.264 2.1482.5635 2.9107.308.7889.72 1.4573 1.388 2.1228.6679.6655 1.3365 1.0743 2.1285 1.38.7632.295 1.6361.4961 2.9134.552 1.2773.056 1.6884.069 4.9462.0627 3.2578-.0062 3.668-.0207 4.9478-.0814 1.28-.0607 2.147-.2652 2.9098-.5633.7889-.3086 1.4578-.72 2.1228-1.3881.665-.6682 1.0745-1.3378 1.3795-2.1284.2957-.7632.4966-1.636.552-2.9124.056-1.2809.0692-1.6898.063-4.948-.0063-3.2583-.021-3.6668-.0817-4.9465-.0607-1.2797-.264-2.1487-.5633-2.9117-.3084-.7889-.72-1.4568-1.3876-2.1228C21.2982 1.33 20.628.9208 19.8378.6165 19.074.321 18.2017.1197 16.9244.0645 15.6471.0093 15.236-.005 11.977.0014 8.718.0076 8.31.0215 7.0301.0839m.1402 21.6932c-1.17-.0509-1.8053-.2453-2.2287-.408-.5606-.216-.96-.4771-1.3819-.895-.422-.4178-.6811-.8186-.9-1.378-.1644-.4234-.3624-1.058-.4171-2.228-.0595-1.2645-.072-1.6442-.079-4.848-.007-3.2037.0053-3.583.0607-4.848.05-1.169.2456-1.805.408-2.2282.216-.5613.4762-.96.895-1.3816.4188-.4217.8184-.6814 1.3783-.9003.423-.1651 1.0575-.3614 2.227-.4171 1.2655-.06 1.6447-.072 4.848-.079 3.2033-.007 3.5835.005 4.8495.0608 1.169.0508 1.8053.2445 2.228.408.5608.216.96.4754 1.3816.895.4217.4194.6816.8176.9005 1.3787.1653.4217.3617 1.056.4169 2.2263.0602 1.2655.0739 1.645.0796 4.848.0058 3.203-.0055 3.5834-.061 4.848-.051 1.17-.245 1.8055-.408 2.2294-.216.5604-.4763.96-.8954 1.3814-.419.4215-.8181.6811-1.3783.9-.4224.1649-1.0577.3617-2.2262.4174-1.2656.0595-1.6448.072-4.8493.079-3.2045.007-3.5825-.006-4.848-.0608M16.953 5.5864A1.44 1.44 0 1 0 18.39 4.144a1.44 1.44 0 0 0-1.437 1.4424M5.8385 12.012c.0067 3.4032 2.7706 6.1557 6.173 6.1493 3.4026-.0065 6.157-2.7701 6.1506-6.1733-.0065-3.4032-2.771-6.1565-6.174-6.1498-3.403.0067-6.156 2.771-6.1496 6.1738M8 12.0077a4 4 0 1 1 4.008 3.9921A3.9996 3.9996 0 0 1 8 12.0077"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/linkedin.svg b/apps/extension/public/platform-icons/linkedin.svg
new file mode 100644
index 00000000..509b178b
--- /dev/null
+++ b/apps/extension/public/platform-icons/linkedin.svg
@@ -0,0 +1 @@
+<svg fill="#0a66c2" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>LinkedIn</title><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/medium.svg b/apps/extension/public/platform-icons/medium.svg
new file mode 100644
index 00000000..e3f348a8
--- /dev/null
+++ b/apps/extension/public/platform-icons/medium.svg
@@ -0,0 +1 @@
+<svg fill="#171717" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Medium</title><path d="M4.21 0A4.201 4.201 0 0 0 0 4.21v15.58A4.201 4.201 0 0 0 4.21 24h15.58A4.201 4.201 0 0 0 24 19.79v-1.093c-.137.013-.278.02-.422.02-2.577 0-4.027-2.146-4.09-4.832a7.592 7.592 0 0 1 .022-.708c.093-1.186.475-2.241 1.105-3.022a3.885 3.885 0 0 1 1.395-1.1c.468-.237 1.127-.367 1.664-.367h.023c.101 0 .202.004.303.01V4.211A4.201 4.201 0 0 0 19.79 0Zm.198 5.583h4.165l3.588 8.435 3.59-8.435h3.864v.146l-.019.004c-.705.16-1.063.397-1.063 1.254h-.003l.003 10.274c.06.676.424.885 1.063 1.03l.02.004v.145h-4.923v-.145l.019-.005c.639-.144.994-.353 1.054-1.03V7.267l-4.745 11.15h-.261L6.15 7.569v9.445c0 .857.358 1.094 1.063 1.253l.02.004v.147H4.405v-.147l.019-.004c.705-.16 1.065-.397 1.065-1.253V6.987c0-.857-.358-1.094-1.064-1.254l-.018-.004zm19.25 3.668c-1.086.023-1.733 1.323-1.813 3.124H24V9.298a1.378 1.378 0 0 0-.342-.047Zm-1.862 3.632c-.1 1.756.86 3.239 2.204 3.634v-3.634z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/reddit.svg b/apps/extension/public/platform-icons/reddit.svg
new file mode 100644
index 00000000..1f514208
--- /dev/null
+++ b/apps/extension/public/platform-icons/reddit.svg
@@ -0,0 +1 @@
+<svg fill="#ff4500" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Reddit</title><path d="M12 0C5.373 0 0 5.373 0 12c0 3.314 1.343 6.314 3.515 8.485l-2.286 2.286C.775 23.225 1.097 24 1.738 24H12c6.627 0 12-5.373 12-12S18.627 0 12 0Zm4.388 3.199c1.104 0 1.999.895 1.999 1.999 0 1.105-.895 2-1.999 2-.946 0-1.739-.657-1.947-1.539v.002c-1.147.162-2.032 1.15-2.032 2.341v.007c1.776.067 3.4.567 4.686 1.363.473-.363 1.064-.58 1.707-.58 1.547 0 2.802 1.254 2.802 2.802 0 1.117-.655 2.081-1.601 2.531-.088 3.256-3.637 5.876-7.997 5.876-4.361 0-7.905-2.617-7.998-5.87-.954-.447-1.614-1.415-1.614-2.538 0-1.548 1.255-2.802 2.803-2.802.645 0 1.239.218 1.712.585 1.275-.79 2.881-1.291 4.64-1.365v-.01c0-1.663 1.263-3.034 2.88-3.207.188-.911.993-1.595 1.959-1.595Zm-8.085 8.376c-.784 0-1.459.78-1.506 1.797-.047 1.016.64 1.429 1.426 1.429.786 0 1.371-.369 1.418-1.385.047-1.017-.553-1.841-1.338-1.841Zm7.406 0c-.786 0-1.385.824-1.338 1.841.047 1.017.634 1.385 1.418 1.385.785 0 1.473-.413 1.426-1.429-.046-1.017-.721-1.797-1.506-1.797Zm-3.703 4.013c-.974 0-1.907.048-2.77.135-.147.015-.241.168-.183.305.483 1.154 1.622 1.964 2.953 1.964 1.33 0 2.47-.81 2.953-1.964.057-.137-.037-.29-.184-.305-.863-.087-1.795-.135-2.769-.135Z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/substack.svg b/apps/extension/public/platform-icons/substack.svg
new file mode 100644
index 00000000..d5f1fc47
--- /dev/null
+++ b/apps/extension/public/platform-icons/substack.svg
@@ -0,0 +1 @@
+<svg fill="#ff6719" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Substack</title><path d="M22.539 8.242H1.46V5.406h21.08v2.836zM1.46 10.812V24L12 18.11 22.54 24V10.812H1.46zM22.54 0H1.46v2.836h21.08V0z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/threads.svg b/apps/extension/public/platform-icons/threads.svg
new file mode 100644
index 00000000..1288ad5f
--- /dev/null
+++ b/apps/extension/public/platform-icons/threads.svg
@@ -0,0 +1 @@
+<svg fill="#171717" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Threads</title><path d="M18.263 11.097c-.03-3.486-1.92-5.586-5.111-5.586-2.13 0-3.922.963-4.863 2.499l2.062 1.438c.535-.843 1.272-1.543 2.628-1.543 1.528 0 2.318.85 2.544 2.431a15 15 0 0 0-2.236-.173c-4.125 0-6.068 1.867-6.068 4.336s1.943 3.99 4.804 3.99c3.139 0 5.013-2.115 5.781-4.735.798.361 1.348 1.204 1.348 2.47 0 3.387-3.907 5.232-7.22 5.232-4.885 0-8.077-3.207-8.077-8.424 0-6.392 4.223-10.487 9.9-10.487 3.808 0 5.69 1.671 6.97 3.914l2.108-1.475C21.44 2.078 18.331 0 13.663 0 6.227 0 1.168 5.277 1.168 12.934c0 7 4.953 11.066 10.856 11.066 4.878 0 9.809-2.846 9.809-7.716 0-2.545-1.46-4.231-3.569-5.187m-6.33 4.855c-1.077 0-2.026-.512-2.026-1.453 0-1.483 1.822-1.934 3.606-1.934.678 0 1.34.045 1.927.173-.422 1.927-1.671 3.215-3.508 3.214Z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/v2ex.svg b/apps/extension/public/platform-icons/v2ex.svg
new file mode 100644
index 00000000..472515ca
--- /dev/null
+++ b/apps/extension/public/platform-icons/v2ex.svg
@@ -0,0 +1 @@
+<svg fill="#555" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>V2EX</title><path d="M.671 1.933h13.821a1.342 1.342 0 0 1 .98.425l8.166 8.725a1.342 1.342 0 0 1 0 1.834l-8.166 8.724a1.342 1.342 0 0 1-.98.426H.673A.671.671 0 0 1 0 21.395v-6.878h13.19l2.276-2.28a.336.336 0 0 0 0-.474l-2.276-2.28H0V2.604a.671.671 0 0 1 .671-.671Z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/x.svg b/apps/extension/public/platform-icons/x.svg
new file mode 100644
index 00000000..2c311c97
--- /dev/null
+++ b/apps/extension/public/platform-icons/x.svg
@@ -0,0 +1 @@
+<svg fill="#171717" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>X</title><path d="M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/xiaohongshu.svg b/apps/extension/public/platform-icons/xiaohongshu.svg
new file mode 100644
index 00000000..91f348cc
--- /dev/null
+++ b/apps/extension/public/platform-icons/xiaohongshu.svg
@@ -0,0 +1 @@
+<svg fill="#ff2442" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Xiaohongshu</title><path d="M22.405 9.879c.002.016.01.02.07.019h.725a.797.797 0 0 0 .78-.972.794.794 0 0 0-.884-.618.795.795 0 0 0-.692.794c0 .101-.002.666.001.777zm-11.509 4.808c-.203.001-1.353.004-1.685.003a2.528 2.528 0 0 1-.766-.126.025.025 0 0 0-.03.014L7.7 16.127a.025.025 0 0 0 .01.032c.111.06.336.124.495.124.66.01 1.32.002 1.981 0 .01 0 .02-.006.023-.015l.712-1.545a.025.025 0 0 0-.024-.036zM.477 9.91c-.071 0-.076.002-.076.01a.834.834 0 0 0-.01.08c-.027.397-.038.495-.234 3.06-.012.24-.034.389-.135.607-.026.057-.033.042.003.112.046.092.681 1.523.787 1.74.008.015.011.02.017.02.008 0 .033-.026.047-.044.147-.187.268-.391.371-.606.306-.635.44-1.325.486-1.706.014-.11.021-.22.03-.33l.204-2.616.022-.293c.003-.029 0-.033-.03-.034zm7.203 3.757a1.427 1.427 0 0 1-.135-.607c-.004-.084-.031-.39-.235-3.06a.443.443 0 0 0-.01-.082c-.004-.011-.052-.008-.076-.008h-1.48c-.03.001-.034.005-.03.034l.021.293c.076.982.153 1.964.233 2.946.05.4.186 1.085.487 1.706.103.215.223.419.37.606.015.018.037.051.048.049.02-.003.742-1.642.804-1.765.036-.07.03-.055.003-.112zm3.861-.913h-.872a.126.126 0 0 1-.116-.178l1.178-2.625a.025.025 0 0 0-.023-.035l-1.318-.003a.148.148 0 0 1-.135-.21l.876-1.954a.025.025 0 0 0-.023-.035h-1.56c-.01 0-.02.006-.024.015l-.926 2.068c-.085.169-.314.634-.399.938a.534.534 0 0 0-.02.191.46.46 0 0 0 .23.378.981.981 0 0 0 .46.119h.59c.041 0-.688 1.482-.834 1.972a.53.53 0 0 0-.023.172.465.465 0 0 0 .23.398c.15.092.342.12.475.12l1.66-.001c.01 0 .02-.006.023-.015l.575-1.28a.025.025 0 0 0-.024-.035zm-6.93-4.937H3.1a.032.032 0 0 0-.034.033c0 1.048-.01 2.795-.01 6.829 0 .288-.269.262-.28.262h-.74c-.04.001-.044.004-.04.047.001.037.465 1.064.555 1.263.01.02.03.033.051.033.157.003.767.009.938-.014.153-.02.3-.06.438-.132.3-.156.49-.419.595-.765.052-.172.075-.353.075-.533.002-2.33 0-4.66-.007-6.991a.032.032 0 0 0-.032-.032zm11.784 6.896c0-.014-.01-.021-.024-.022h-1.465c-.048-.001-.049-.002-.05-.049v-4.66c0-.072-.005-.07.07-.07h.863c.08 0 .075.004.075-.074V8.393c0-.082.006-.076-.08-.076h-3.5c-.064 0-.075-.006-.075.073v1.445c0 .083-.006.077.08.077h.854c.075 0 .07-.004.07.07v4.624c0 .095.008.084-.085.084-.37 0-1.11-.002-1.304 0-.048.001-.06.03-.06.03l-.697 1.519s-.014.025-.008.036c.006.01.013.008.058.008 1.748.003 3.495.002 5.243.002.03-.001.034-.006.035-.033v-1.539zm4.177-3.43c0 .013-.007.023-.02.024-.346.006-.692.004-1.037.004-.014-.002-.022-.01-.022-.024-.005-.434-.007-.869-.01-1.303 0-.072-.006-.071.07-.07l.733-.003c.041 0 .081.002.12.015.093.025.16.107.165.204.006.431.002 1.153.001 1.153zm2.67.244a1.953 1.953 0 0 0-.883-.222h-.18c-.04-.001-.04-.003-.042-.04V10.21c0-.132-.007-.263-.025-.394a1.823 1.823 0 0 0-.153-.53 1.533 1.533 0 0 0-.677-.71 2.167 2.167 0 0 0-1-.258c-.153-.003-.567 0-.72 0-.07 0-.068.004-.068-.065V7.76c0-.031-.01-.041-.046-.039H17.93s-.016 0-.023.007c-.006.006-.008.012-.008.023v.546c-.008.036-.057.015-.082.022h-.95c-.022.002-.028.008-.03.032v1.481c0 .09-.004.082.082.082h.913c.082 0 .072.128.072.128V11.19s.003.117-.06.117h-1.482c-.068 0-.06.082-.06.082v1.445s-.01.068.064.068h1.457c.082 0 .076-.006.076.079v3.225c0 .088-.007.081.082.081h1.43c.09 0 .082.007.082-.08v-3.27c0-.029.006-.035.033-.035l2.323-.003c.098 0 .191.02.28.061a.46.46 0 0 1 .274.407c.008.395.003.79.003 1.185 0 .259-.107.367-.33.367h-1.218c-.023.002-.029.008-.028.033.184.437.374.871.57 1.303a.045.045 0 0 0 .04.026c.17.005.34.002.51.003.15-.002.517.004.666-.01a2.03 2.03 0 0 0 .408-.075c.59-.18.975-.698.976-1.313v-1.981c0-.128-.01-.254-.034-.38 0 .078-.029-.641-.724-.998z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/xiaoyuzhou.png b/apps/extension/public/platform-icons/xiaoyuzhou.png
new file mode 100644
index 00000000..98c4981b
Binary files /dev/null and b/apps/extension/public/platform-icons/xiaoyuzhou.png differ
diff --git a/apps/extension/public/platform-icons/youtube.svg b/apps/extension/public/platform-icons/youtube.svg
new file mode 100644
index 00000000..e72a2973
--- /dev/null
+++ b/apps/extension/public/platform-icons/youtube.svg
@@ -0,0 +1 @@
+<svg fill="#f03" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>YouTube</title><path d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/public/platform-icons/zhihu.svg b/apps/extension/public/platform-icons/zhihu.svg
new file mode 100644
index 00000000..22fb6b69
--- /dev/null
+++ b/apps/extension/public/platform-icons/zhihu.svg
@@ -0,0 +1 @@
+<svg fill="#1772f6" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Zhihu</title><path d="M5.721 0C2.251 0 0 2.25 0 5.719V18.28C0 21.751 2.252 24 5.721 24h12.56C21.751 24 24 21.75 24 18.281V5.72C24 2.249 21.75 0 18.281 0zm1.964 4.078c-.271.73-.5 1.434-.68 2.11h4.587c.545-.006.445 1.168.445 1.171H9.384a58.104 58.104 0 01-.112 3.797h2.712c.388.023.393 1.251.393 1.266H9.183a9.223 9.223 0 01-.408 2.102l.757-.604c.452.456 1.512 1.712 1.906 2.177.473.681.063 2.081.063 2.081l-2.794-3.382c-.653 2.518-1.845 3.607-1.845 3.607-.523.468-1.58.82-2.64.516 2.218-1.73 3.44-3.917 3.667-6.497H4.491c0-.015.197-1.243.806-1.266h2.71c.024-.32.086-3.254.086-3.797H6.598c-.136.406-.158.447-.268.753-.594 1.095-1.603 1.122-1.907 1.155.906-1.821 1.416-3.6 1.591-4.064.425-1.124 1.671-1.125 1.671-1.125zM13.078 6h6.377v11.33h-2.573l-2.184 1.373-.401-1.373h-1.219zm1.313 1.219v8.86h.623l.263.937 1.455-.938h1.456v-8.86z"/></svg>
\ No newline at end of file
diff --git a/apps/extension/src/background.ts b/apps/extension/src/background.ts
index c6bfe08e..d24d3eb6 100644
--- a/apps/extension/src/background.ts
+++ b/apps/extension/src/background.ts
@@ -294,7 +294,7 @@ const imageNoteClient = (settings: ExtensionSettings): ImageNoteClient => ({
const scriptTarget = (tabId: number, frameId: number | null) =>
typeof frameId === "number" ? { tabId, frameIds: [frameId] } : { tabId };
-const injectImageHelper = async (tabId: number, frameId: number | null, payload: unknown) => {
+const injectImageHelper = async (tabId: number, frameId: number | null, payload: { action: string; [key: string]: unknown }) => {
const target = scriptTarget(tabId, frameId);
await chrome.scripting.executeScript({
target,
@@ -305,7 +305,7 @@ const injectImageHelper = async (tabId: number, frameId: number | null, payload:
});
await chrome.scripting.executeScript({
target,
- files: ["assets/capture-image.js"],
+ files: [payload.action === "toast" ? "assets/clip-feedback.js" : "assets/capture-image.js"],
});
};
@@ -313,17 +313,17 @@ const showFeedback = async (
tabId: number | null,
frameId: number | null,
message: string,
- kind: "success" | "error",
+ kind: "normal" | "success" | "error",
) => {
if (tabId) {
try {
- await injectImageHelper(tabId, frameId, { action: "toast", message, kind });
+ await injectImageHelper(tabId, frameId, { action: "toast", message, kind, closeLabel: t("closeNotification"), regionLabel: t("clipNotifications") });
return;
} catch {
// Restricted pages cannot host the toast. The toolbar badge still reports the result.
}
}
- await chrome.action.setBadgeBackgroundColor({ color: kind === "error" ? "#b91c1c" : "#0f766e" });
+ await chrome.action.setBadgeBackgroundColor({ color: kind === "error" ? "#b91c1c" : "#171717" });
await chrome.action.setBadgeText({ text: kind === "error" ? "!" : "✓" });
setTimeout(() => {
void chrome.action.setBadgeText({ text: "" });
@@ -640,7 +640,7 @@ const saveImageFromMenu = async (
try {
await ensureClipperReady();
if (!srcUrl) throw new Error(t("imageUnreadable"));
- await showFeedback(tabId, frameId, t("savingImage"), "success");
+ await showFeedback(tabId, frameId, t("savingImage"), "normal");
const inlineImage = imageFromDataUrl(srcUrl);
if (inlineImage && !("error" in inlineImage)) {
const settings = await ensureClipperReady();
@@ -688,7 +688,7 @@ const saveImageFromMenu = async (
originPattern,
host,
});
- await showFeedback(tabId, frameId, t("imagePermissionToast"), "success");
+ await showFeedback(tabId, frameId, t("imagePermissionToast"), "normal");
} catch (error) {
await reportImageFailure(tabId, frameId, error);
}
@@ -783,15 +783,15 @@ const saveTweetFromMenu = async (
const statusId = statusIdFromPageUrl(pageUrl);
if (!statusId && !await hasTweetSitePermission(pageUrl)) {
await openTweetPermissionWindow(tabId);
- await showFeedback(tabId, frameId, t("tweetPermissionToast"), "success");
+ await showFeedback(tabId, frameId, t("tweetPermissionToast"), "normal");
return;
}
- await showFeedback(tabId, frameId, t("savingTweet"), "success");
+ await showFeedback(tabId, frameId, t("savingTweet"), "normal");
const tweet = await readTweetFromPage(tabId, frameId, statusId);
if (!tweet.ok && tweet.reason === "needs-listener") {
await injectTweetTarget(tabId);
- await showFeedback(tabId, frameId, t("tweetRightClickAgain"), "success");
+ await showFeedback(tabId, frameId, t("tweetRightClickAgain"), "normal");
return;
}
if (!tweet.ok) throw new Error(t("tweetNotFound"));
@@ -904,15 +904,15 @@ const saveXhsFromMenu = async (
const noteId = noteIdFromPageUrl(pageUrl);
if (!noteId && !await hasTweetSitePermission(pageUrl)) {
await openXhsPermissionWindow(tabId);
- await showFeedback(tabId, frameId, t("xhsPermissionToast"), "success");
+ await showFeedback(tabId, frameId, t("xhsPermissionToast"), "normal");
return;
}
- await showFeedback(tabId, frameId, t("savingXhs"), "success");
+ await showFeedback(tabId, frameId, t("savingXhs"), "normal");
const page = await readXhsStateFromPage(tabId, frameId) ?? await readXhsFromPage(tabId, frameId);
if (!page.ok && page.reason === "needs-listener") {
await injectXhsTarget(tabId);
- await showFeedback(tabId, frameId, t("xhsRightClickAgain"), "success");
+ await showFeedback(tabId, frameId, t("xhsRightClickAgain"), "normal");
return;
}
if (!page.ok && page.reason === "needs-open") throw new Error(t("xhsNeedsOpen"));
@@ -1074,7 +1074,7 @@ const saveZhihuFromMenu = async (
const raw = error instanceof Error ? error.message : String(error);
if (/cannot access|missing host permission|permission/i.test(raw)) {
await openZhihuPermissionWindow(tabId);
- await showFeedback(tabId, frameId, t("zhihuPermissionToast"), "success");
+ await showFeedback(tabId, frameId, t("zhihuPermissionToast"), "normal");
return;
}
throw error;
@@ -1082,15 +1082,15 @@ const saveZhihuFromMenu = async (
if (!located.ok && located.reason === "needs-listener") {
try {
await injectZhihuTarget(tabId);
- await showFeedback(tabId, frameId, t("zhihuRightClickAgain"), "success");
+ await showFeedback(tabId, frameId, t("zhihuRightClickAgain"), "normal");
} catch {
await openZhihuPermissionWindow(tabId);
- await showFeedback(tabId, frameId, t("zhihuPermissionToast"), "success");
+ await showFeedback(tabId, frameId, t("zhihuPermissionToast"), "normal");
}
return;
}
if (!located.ok) throw new Error(t("zhihuNotFound"));
- await showFeedback(tabId, frameId, t("savingZhihu"), "success");
+ await showFeedback(tabId, frameId, t("savingZhihu"), "normal");
await saveLocatedZhihu(settings, tabId, frameId, located);
await showFeedback(tabId, frameId, t("zhihuSaved"), "success");
} catch (error) {
@@ -1145,13 +1145,13 @@ const saveRedditFromMenu = async (
const result = await readRedditFromPage(tabId, frameId, info.linkUrl || tab?.url || info.pageUrl || "");
if (result.ok === false && result.reason === "needs-listener") {
await chrome.scripting.executeScript({ target: { tabId }, files: ["assets/reddit-target.js"] });
- await showFeedback(tabId, frameId, t("redditRightClickAgain"), "success");
+ await showFeedback(tabId, frameId, t("redditRightClickAgain"), "normal");
return;
}
const id = typeof result.id === "string" ? result.id : "";
const post = redditPostFromApi(result.api, id) ?? redditPostFromDom(result.dom, id);
if (!post) throw new Error(t("redditNotFound"));
- await showFeedback(tabId, frameId, t("savingReddit"), "success");
+ await showFeedback(tabId, frameId, t("savingReddit"), "normal");
const images = [];
for (const image of post.images) {
const stored = await readTweetImage(tabId, frameId, image.url, image.alt || post.title);
@@ -1272,7 +1272,7 @@ const saveGithubRepoFromMenu = async (
await showFeedback(tabId, frameId, t("githubRepoUnreadable"), "error");
return;
}
- await showFeedback(tabId, frameId, t("savingGithubRepo"), "success");
+ await showFeedback(tabId, frameId, t("savingGithubRepo"), "normal");
await createGithubRepoMemo(settings, facts);
await showFeedback(tabId, frameId, t("githubRepoSaved"), "success");
} catch (error) {
@@ -1374,7 +1374,7 @@ const savePlatformFromMenu = async (info: { pageUrl?: string; frameId?: number }
const tabId = typeof tab?.id === "number" ? tab.id : null;
try {
if (tabId === null || (info.frameId ?? 0) !== 0) throw new Error(t("platformNotDetail"));
- await showFeedback(tabId, 0, t("savingPlatformClip"), "success");
+ await showFeedback(tabId, 0, t("savingPlatformClip"), "normal");
const pageUrl = info.pageUrl || tab?.url || "";
let selectedUrl = pageUrl;
if (socialPlatform(pageUrl)) {
@@ -1468,7 +1468,7 @@ const saveSelectionFromMenu = async (
try {
const settings = await ensureClipperReady();
if (!tabId) throw new Error(t("selectionEmpty"));
- await showFeedback(tabId, frameId, t("savingSelection"), "success");
+ await showFeedback(tabId, frameId, t("savingSelection"), "normal");
let captured: CapturedPage | null = null;
try {
captured = await readCapturedPage(tabId, frameId, "selection");
@@ -1615,7 +1615,7 @@ const saveVideoFromMenu = async (
try {
const settings = await ensureClipperReady();
if (!tabId) throw new Error(t("videoNotRead"));
- await showFeedback(tabId, frameId, t("savingVideoNote"), "success");
+ await showFeedback(tabId, frameId, t("savingVideoNote"), "normal");
const result = await performVideoSave(settings, tabId, frameId, pageUrl);
await showFeedback(tabId, frameId, result.message, result.created ? "success" : "error");
} catch (error) {
@@ -1941,7 +1941,7 @@ chrome.runtime.onMessage.addListener((message: { type?: string; page?: unknown;
return;
}
try {
- await showFeedback(pending.tabId, pending.frameId, t("savingImage"), "success");
+ await showFeedback(pending.tabId, pending.frameId, t("savingImage"), "normal");
await saveDownloadedImage(pending, "");
sendResponse({ ok: true });
} catch (error) {
diff --git a/apps/extension/src/capture-image.ts b/apps/extension/src/capture-image.ts
index ee870367..dacf5138 100644
--- a/apps/extension/src/capture-image.ts
+++ b/apps/extension/src/capture-image.ts
@@ -43,37 +43,6 @@
return btoa(binary);
};
- const showToast = (message: string, kind: string) => {
- document.getElementById("edgeever-clipper-toast")?.remove();
- const host = document.createElement("div");
- host.id = "edgeever-clipper-toast";
- host.style.position = "fixed";
- host.style.zIndex = "2147483647";
- host.style.right = "16px";
- host.style.bottom = "16px";
- host.style.pointerEvents = "none";
- const shadow = host.attachShadow({ mode: "open" });
- const toast = document.createElement("div");
- toast.textContent = message;
- toast.style.cssText = [
- "max-width:280px",
- "padding:12px 14px",
- "border-radius:10px",
- `background:${kind === "error" ? "#b91c1c" : "#0f766e"}`,
- "color:#fff",
- "font:600 13px/1.45 -apple-system,BlinkMacSystemFont,\"Segoe UI\",sans-serif",
- "box-shadow:0 8px 24px rgb(15 23 42 / 24%)",
- ].join(";");
- shadow.appendChild(toast);
- (document.documentElement ?? document.body).appendChild(host);
- window.setTimeout(() => host.remove(), kind === "error" ? 8000 : 4000);
- };
-
- if (payload.action === "toast") {
- showToast(typeof payload.message === "string" ? payload.message : "", payload.kind === "error" ? "error" : "success");
- return;
- }
-
if (payload.action !== "read" || typeof payload.requestId !== "string") return;
const requestId = payload.requestId;
diff --git a/apps/extension/src/diagnostics.ts b/apps/extension/src/diagnostics.ts
new file mode 100644
index 00000000..d4d71165
--- /dev/null
+++ b/apps/extension/src/diagnostics.ts
@@ -0,0 +1,65 @@
+import type { ExtensionSettings } from "./extension";
+import { t } from "./i18n";
+
+export type DiagnosticInfo = {
+ extensionVersion: string;
+ manifestVersion: string;
+ browser: string;
+ system: string;
+ extensionId: string;
+ instanceOrigin: string;
+ instancePermission: string;
+};
+
+const getBrowserLabel = () => {
+ const userAgent = navigator.userAgent;
+ const match = userAgent.match(/(Edg|Chrome|Firefox|Version)\/([\d.]+)/);
+ if (!match) {
+ return userAgent;
+ }
+ const name = match[1] === "Edg" ? "Microsoft Edge" : match[1] === "Version" ? "Safari" : match[1];
+ return `${name} ${match[2]}`;
+};
+
+const getInstanceOrigin = (instanceUrl: string) => {
+ if (!instanceUrl) {
+ return t("notConfigured");
+ }
+ try {
+ return new URL(instanceUrl).origin;
+ } catch {
+ return t("invalidInstanceAddress");
+ }
+};
+
+export const getDiagnosticInfo = async (settings: ExtensionSettings): Promise<DiagnosticInfo> => {
+ const manifest = chrome.runtime.getManifest() as { manifest_version?: number; version?: string };
+ const instanceOrigin = getInstanceOrigin(settings.instanceUrl);
+ let instancePermission = t("permissionNotConfigured");
+ if (instanceOrigin.startsWith("http")) {
+ const granted = await chrome.permissions.contains({ origins: [`${instanceOrigin}/*`] });
+ instancePermission = granted ? t("permissionGranted") : t("permissionNotGranted");
+ }
+
+ return {
+ extensionVersion: manifest.version || t("unknownValue"),
+ manifestVersion: manifest.manifest_version ? String(manifest.manifest_version) : t("unknownValue"),
+ browser: getBrowserLabel(),
+ system: `${navigator.platform || t("unknownValue")} (${navigator.language || t("unknownValue")})`,
+ extensionId: chrome.runtime.id || t("unknownValue"),
+ instanceOrigin,
+ instancePermission,
+ };
+};
+
+export const diagnosticText = (info: DiagnosticInfo) => [
+ "EdgeEver Web Clipper diagnostics",
+ `Extension version: ${info.extensionVersion}`,
+ `Manifest version: ${info.manifestVersion}`,
+ `Browser: ${info.browser}`,
+ `System: ${info.system}`,
+ `Extension ID: ${info.extensionId}`,
+ `Instance origin: ${info.instanceOrigin}`,
+ `Instance permission: ${info.instancePermission}`,
+ "Declared permissions: activeTab, scripting, storage",
+].join("\n");
diff --git a/apps/extension/src/image-save.ts b/apps/extension/src/image-save.ts
deleted file mode 100644
index 70314325..00000000
--- a/apps/extension/src/image-save.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-import "./styles.css";
-import { localizeDocument, t } from "./i18n";
-
-localizeDocument();
-document.title = t("imageSaveWindowTitle");
-
-const hostLine = document.querySelector<HTMLParagraphElement>("#host");
-const status = document.querySelector<HTMLParagraphElement>("#status");
-const allowButton = document.querySelector<HTMLButtonElement>("#allow");
-const allowAllButton = document.querySelector<HTMLButtonElement>("#allow-all");
-
-const setStatus = (message: string, kind: "normal" | "error" | "success" = "normal") => {
- if (!status) return;
- status.textContent = message;
- status.dataset.kind = kind;
-};
-
-const grant = async (origins: string[]) => {
- if (!allowButton || !allowAllButton) return;
- allowButton.disabled = true;
- allowAllButton.disabled = true;
- let granted = false;
- try {
- granted = await chrome.permissions.request({ origins });
- } catch {
- granted = false;
- }
- if (!granted) {
- setStatus(t("imagePermissionDenied"), "error");
- allowButton.disabled = false;
- allowAllButton.disabled = false;
- return;
- }
-
- setStatus(t("savingImage"));
- try {
- const response = await chrome.runtime.sendMessage({ type: "completePendingImageSave" }) as { ok?: boolean; message?: string } | undefined;
- if (!response?.ok) {
- setStatus(response?.message || t("saveFailed"), "error");
- allowButton.disabled = false;
- allowAllButton.disabled = false;
- return;
- }
- } catch (error) {
- setStatus(error instanceof Error ? error.message : t("saveFailed"), "error");
- allowButton.disabled = false;
- allowAllButton.disabled = false;
- return;
- }
-
- setStatus(t("imageSaved"), "success");
- window.setTimeout(() => window.close(), 700);
-};
-
-void chrome.runtime.sendMessage({ type: "getPendingImageSave" }).then((pending: { originPattern?: string; host?: string } | null) => {
- if (!pending?.originPattern || !allowButton || !allowAllButton) {
- setStatus(t("imageSaveExpired"), "error");
- return;
- }
- if (hostLine && pending.host) hostLine.textContent = t("imagePermissionHost", pending.host);
- allowButton.disabled = false;
- allowAllButton.disabled = false;
- allowButton.addEventListener("click", () => {
- void grant([pending.originPattern as string]);
- });
- allowAllButton.addEventListener("click", () => {
- void grant(["https://*/*", "http://*/*"]);
- });
-}).catch(() => {
- setStatus(t("imageSaveExpired"), "error");
-});
diff --git a/apps/extension/src/options.ts b/apps/extension/src/options.ts
deleted file mode 100644
index 1a047376..00000000
--- a/apps/extension/src/options.ts
+++ /dev/null
@@ -1,172 +0,0 @@
-import "./styles.css";
-import { getSettings, saveSettings, testConnection, type ExtensionSettings } from "./extension";
-import { localizeDocument, t } from "./i18n";
-
-localizeDocument();
-
-type NotebookSelect = {
- value: string;
- replaceChildren: (...nodes: Node[]) => void;
- add: (option: HTMLOptionElement) => void;
-};
-
-const form = document.querySelector<HTMLFormElement>("#settings-form");
-const instanceUrlInput = document.querySelector<HTMLInputElement>("#instance-url");
-const tokenInput = document.querySelector<HTMLInputElement>("#token");
-const notebookSelect = document.querySelector("#notebook-id") as NotebookSelect | null;
-const testButton = document.querySelector<HTMLButtonElement>("#test");
-const status = document.querySelector<HTMLParagraphElement>("#status");
-const copyDiagnosticsButton = document.querySelector<HTMLButtonElement>("#copy-diagnostics");
-const copyStatus = document.querySelector<HTMLSpanElement>("#copy-status");
-
-type DiagnosticInfo = {
- extensionVersion: string;
- manifestVersion: string;
- browser: string;
- system: string;
- extensionId: string;
- instanceOrigin: string;
- instancePermission: string;
-};
-
-const setStatus = (message: string, kind: "normal" | "error" | "success" = "normal") => {
- if (status) {
- status.textContent = message;
- status.dataset.kind = kind;
- }
-};
-
-const readSettings = (): ExtensionSettings => ({
- instanceUrl: instanceUrlInput?.value.trim() ?? "",
- token: tokenInput?.value.trim() ?? "",
- notebookId: notebookSelect?.value ?? "",
-});
-
-const getBrowserLabel = () => {
- const userAgent = navigator.userAgent;
- const match = userAgent.match(/(Edg|Chrome|Firefox|Version)\/([\d.]+)/);
- if (!match) {
- return userAgent;
- }
- const name = match[1] === "Edg" ? "Microsoft Edge" : match[1] === "Version" ? "Safari" : match[1];
- return `${name} ${match[2]}`;
-};
-
-const getInstanceOrigin = (instanceUrl: string) => {
- if (!instanceUrl) {
- return t("notConfigured");
- }
- try {
- return new URL(instanceUrl).origin;
- } catch {
- return t("invalidInstanceAddress");
- }
-};
-
-const getDiagnosticInfo = async (settings: ExtensionSettings): Promise<DiagnosticInfo> => {
- const manifest = chrome.runtime.getManifest() as { manifest_version?: number; version?: string };
- const instanceOrigin = getInstanceOrigin(settings.instanceUrl);
- let instancePermission = t("permissionNotConfigured");
- if (instanceOrigin.startsWith("http")) {
- const granted = await chrome.permissions.contains({ origins: [`${instanceOrigin}/*`] });
- instancePermission = granted ? t("permissionGranted") : t("permissionNotGranted");
- }
-
- return {
- extensionVersion: manifest.version || t("unknownValue"),
- manifestVersion: manifest.manifest_version ? String(manifest.manifest_version) : t("unknownValue"),
- browser: getBrowserLabel(),
- system: `${navigator.platform || t("unknownValue")} (${navigator.language || t("unknownValue")})`,
- extensionId: chrome.runtime.id || t("unknownValue"),
- instanceOrigin,
- instancePermission,
- };
-};
-
-const diagnosticText = (info: DiagnosticInfo) => [
- "EdgeEver Web Clipper diagnostics",
- `Extension version: ${info.extensionVersion}`,
- `Manifest version: ${info.manifestVersion}`,
- `Browser: ${info.browser}`,
- `System: ${info.system}`,
- `Extension ID: ${info.extensionId}`,
- `Instance origin: ${info.instanceOrigin}`,
- `Instance permission: ${info.instancePermission}`,
- "Declared permissions: activeTab, scripting, storage",
-].join("\n");
-
-const setCopyStatus = (message: string, kind: "normal" | "error" | "success" = "normal") => {
- if (copyStatus) {
- copyStatus.textContent = message;
- copyStatus.dataset.kind = kind;
- }
-};
-
-const renderNotebooks = (notebooks: Array<{ id: string; name: string }>, selectedId: string) => {
- if (!notebookSelect) {
- return;
- }
-
- notebookSelect.replaceChildren(new Option(t("autoFirstNotebook"), ""));
- for (const notebook of notebooks) {
- notebookSelect.add(new Option(notebook.name, notebook.id));
- }
- notebookSelect.value = selectedId;
-};
-
-const initialize = async () => {
- const settings = await getSettings();
- if (instanceUrlInput) instanceUrlInput.value = settings.instanceUrl;
- if (tokenInput) tokenInput.value = settings.token;
- if (notebookSelect) notebookSelect.value = settings.notebookId;
-
- const info = await getDiagnosticInfo(settings);
- document.querySelector("#extension-version")!.textContent = info.extensionVersion;
- document.querySelector("#manifest-version")!.textContent = info.manifestVersion;
- document.querySelector("#browser-version")!.textContent = info.browser;
- document.querySelector("#system-version")!.textContent = info.system;
- document.querySelector("#extension-id")!.textContent = info.extensionId;
- document.querySelector("#instance-origin")!.textContent = info.instanceOrigin;
- document.querySelector("#instance-permission")!.textContent = info.instancePermission;
-};
-
-testButton?.addEventListener("click", async () => {
- testButton.disabled = true;
- setStatus(t("connecting"));
- try {
- const settings = readSettings();
- const notebooks = await testConnection(settings);
- renderNotebooks(notebooks, notebookSelect?.value ?? "");
- const messageKey = notebooks.length === 1 ? "connectionSuccessOne" : "connectionSuccessMany";
- setStatus(t(messageKey, String(notebooks.length)), "success");
- } catch (error) {
- setStatus(error instanceof Error ? error.message : t("connectionFailed"), "error");
- } finally {
- testButton.disabled = false;
- }
-});
-
-form?.addEventListener("submit", async (event) => {
- event.preventDefault();
- try {
- await saveSettings(readSettings());
- setStatus(t("settingsSaved"), "success");
- } catch (error) {
- setStatus(error instanceof Error ? error.message : t("settingsSaveFailed"), "error");
- }
-});
-
-copyDiagnosticsButton?.addEventListener("click", async () => {
- copyDiagnosticsButton.disabled = true;
- try {
- const info = await getDiagnosticInfo(readSettings());
- await navigator.clipboard.writeText(diagnosticText(info));
- setCopyStatus(t("diagnosticsCopied"), "success");
- } catch {
- setCopyStatus(t("diagnosticsCopyFailed"), "error");
- } finally {
- copyDiagnosticsButton.disabled = false;
- }
-});
-
-void initialize();
diff --git a/apps/extension/src/popup.ts b/apps/extension/src/popup.ts
index aa82e79b..459c708e 100644
--- a/apps/extension/src/popup.ts
+++ b/apps/extension/src/popup.ts
@@ -1,71 +1,12 @@
-import "./styles.css";
-import { getSettings, requestInstancePermission, type ExtensionSettings } from "./extension";
-import { localizeDocument, t } from "./i18n";
-
-localizeDocument();
-
-const saveButton = document.querySelector<HTMLButtonElement>("#save");
-const settingsButton = document.querySelector<HTMLButtonElement>("#settings");
-const status = document.querySelector<HTMLParagraphElement>("#status");
-const captureMode = document.querySelector<HTMLElement>("#capture-mode");
-const captureContext = document.querySelector<HTMLElement>("#capture-context");
-let settings: ExtensionSettings | null = null;
-let pageUnavailable = false;
-
-const setStatus = (message: string, kind: "normal" | "error" | "success" = "normal") => {
- if (status) {
- status.textContent = message;
- status.dataset.kind = kind;
- }
-};
-
-if (saveButton) saveButton.disabled = true;
-void chrome.runtime.sendMessage({ type:"getCurrentPageCaptureMode" }).then((mode: { kind?: string; platform?: string } | undefined) => {
- pageUnavailable = mode?.kind === 'unavailable';
- if (pageUnavailable && saveButton) saveButton.disabled=true;
- if (captureContext) captureContext.dataset.kind=mode?.platform ? 'adapted' : 'generic';
- if (!captureMode) return;
- captureMode.textContent = !mode || mode.kind === 'unknown' ? t('pageCaptureUnknown')
- : mode.kind === 'unavailable' ? t('pageCaptureUnavailable')
- : mode?.kind === 'social-feed' ? t('pageCaptureSelectPost')
- : mode?.platform ? t('pageCaptureAdapted',mode.platform) : t('pageCaptureGeneric');
- if (captureContext && mode?.platform) {
- captureContext.setAttribute('aria-label', `${mode.platform} · ${captureMode.textContent}`);
- }
-}).catch(() => {
- if (captureMode) captureMode.textContent=t('pageCaptureUnknown');
-});
-void getSettings().then((loadedSettings) => {
- settings = loadedSettings;
- if (saveButton) saveButton.disabled = pageUnavailable;
-}).catch((error: unknown) => {
- setStatus(error instanceof Error ? error.message : t("saveFailed"), "error");
-});
-
-saveButton?.addEventListener("click", async () => {
- if (!settings) return;
- saveButton.disabled = true;
- setStatus(t("readingAndSaving"));
-
- try {
- if (!settings.instanceUrl || !settings.token) {
- throw new Error(t("completePluginConfiguration"));
- }
-
- await requestInstancePermission(settings.instanceUrl);
- const response = await chrome.runtime.sendMessage({ type: "captureCurrentPage" });
- if (!response?.ok) {
- throw new Error(response?.message || t("saveFailed"));
- }
-
- setStatus(typeof response.message === "string" && response.message ? response.message : t("savedToEdgeEver"), "success");
- } catch (error) {
- setStatus(error instanceof Error ? error.message : t("saveFailed"), "error");
- } finally {
- saveButton.disabled = pageUnavailable;
- }
-});
-
-settingsButton?.addEventListener("click", () => {
- void chrome.runtime.openOptionsPage();
-});
+import { requestInstancePermission, type ExtensionSettings } from "./extension";
+import { t } from "./i18n";
+
+// Called directly by the React click handler: request permissions before yielding
+// so Firefox retains the user gesture. UI rendering must never request access.
+export async function captureCurrentPage(settings: ExtensionSettings): Promise<string> {
+ if (!settings.instanceUrl || !settings.token) throw new Error(t("completePluginConfiguration"));
+ await requestInstancePermission(settings.instanceUrl);
+ const response = await chrome.runtime.sendMessage({ type: "captureCurrentPage" });
+ if (!response?.ok) throw new Error(response?.message || t("saveFailed"));
+ return typeof response.message === "string" && response.message ? response.message : t("savedToEdgeEver");
+}
diff --git a/apps/extension/src/styles.css b/apps/extension/src/styles.css
deleted file mode 100644
index 81ee756e..00000000
--- a/apps/extension/src/styles.css
+++ /dev/null
@@ -1,339 +0,0 @@
-:root {
- color: #172033;
- background: #f8fafc;
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
-}
-
-body {
- margin: 0;
- min-width: 320px;
-}
-
-.popup-shell,
-.options-shell {
- box-sizing: border-box;
- margin: 0 auto;
- padding: 24px;
-}
-
-.popup-shell {
- width: 320px;
- padding: 20px;
- background: #f8fafc;
-}
-
-.popup-header {
- display: flex;
- align-items: center;
- gap: 10px;
-}
-
-.popup-header img {
- border-radius: 8px;
- box-shadow: 0 1px 2px rgb(15 23 42 / 12%);
-}
-
-.popup-header h1 {
- margin: 0;
- font-size: 18px;
- line-height: 1.2;
-}
-
-.popup-header .hint {
- margin: 2px 0 0;
- font-size: 12px;
- line-height: 1.4;
-}
-
-.popup-context {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- gap: 4px;
- flex-shrink: 0;
- max-width: 108px;
- margin-left: auto;
- padding: 4px 7px;
- border-radius: 6px;
- background: #eef1f4;
- color: #64748b;
-}
-
-.capture-check {
- display: none;
- flex-shrink: 0;
- fill: none;
- stroke: currentcolor;
- stroke-width: 1.8;
- stroke-linecap: round;
- stroke-linejoin: round;
-}
-
-.popup-context[data-kind="adapted"] {
- background: #e7f5ee;
- color: #13885e;
-}
-
-.popup-context[data-kind="adapted"] .capture-check {
- display: block;
-}
-
-.capture-mode {
- font-size: 11px;
- font-weight: 500;
- line-height: 1.4;
- text-align: center;
- overflow-wrap: anywhere;
-}
-
-.save-button {
- display: inline-flex;
- width: 100%;
- align-items: center;
- justify-content: center;
- gap: 8px;
- min-height: 42px;
- box-shadow: 0 1px 2px rgb(15 118 110 / 18%);
-}
-
-.popup-shell .save-button {
- margin-top: 24px;
- min-height: 44px;
- background: #16a06e;
- border-radius: 10px;
-}
-
-.popup-shell .save-button:hover:not(:disabled) {
- background: #13885e;
-}
-
-.save-button svg,
-.settings-button svg {
- fill: none;
- stroke: currentcolor;
- stroke-linecap: round;
- stroke-linejoin: round;
- stroke-width: 1.8;
-}
-
-.popup-shell .status:empty {
- display: none;
-}
-
-.popup-shell .status {
- min-height: 0;
- margin: 12px 0 0;
-}
-
-.settings-button {
- display: flex;
- width: 100%;
- align-items: center;
- justify-content: center;
- gap: 7px;
- margin-top: 12px;
- border-top: 0;
- border-radius: 0;
- background: transparent;
- color: #64748b;
- padding: 8px 0;
- font-size: 12px;
-}
-
-.settings-button:hover {
- background: transparent;
- color: #115e59;
-}
-
-.options-shell {
- max-width: 640px;
-}
-
-h1 {
- margin: 0 0 8px;
- font-size: 22px;
-}
-
-.diagnostics-panel {
- margin-top: 28px;
- border-top: 1px solid #e2e8f0;
- padding-top: 22px;
-}
-
-.diagnostics-panel h2 {
- margin: 0 0 8px;
- font-size: 17px;
-}
-
-.diagnostics-list {
- margin: 16px 0 0;
- border: 1px solid #e2e8f0;
- border-radius: 8px;
- background: white;
- overflow: hidden;
-}
-
-.diagnostics-list div {
- display: grid;
- grid-template-columns: minmax(150px, 0.8fr) minmax(0, 1.2fr);
- gap: 12px;
- padding: 9px 12px;
- border-bottom: 1px solid #f1f5f9;
- font-size: 12px;
-}
-
-.diagnostics-list div:last-child {
- border-bottom: 0;
-}
-
-.diagnostics-list dt {
- color: #64748b;
-}
-
-.diagnostics-list dd {
- margin: 0;
- overflow-wrap: anywhere;
- color: #172033;
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
-}
-
-.diagnostics-actions {
- display: flex;
- align-items: center;
- gap: 10px;
- margin-top: 12px;
-}
-
-.diagnostics-actions .status {
- min-height: 0;
- margin: 0;
-}
-
-.hint {
- margin: 0 0 20px;
- color: #64748b;
- font-size: 13px;
- line-height: 1.6;
-}
-
-label {
- display: grid;
- gap: 8px;
- margin: 16px 0;
- font-size: 14px;
- font-weight: 600;
-}
-
-input,
-select,
-button {
- box-sizing: border-box;
- border-radius: 8px;
- font: inherit;
-}
-
-input,
-select {
- width: 100%;
- border: 1px solid #cbd5e1;
- background: white;
- padding: 10px 12px;
-}
-
-button {
- border: 0;
- background: #0f766e;
- color: white;
- cursor: pointer;
- padding: 10px 14px;
- font-weight: 600;
-}
-
-button:hover {
- background: #115e59;
-}
-
-button:disabled {
- cursor: wait;
- opacity: 0.6;
-}
-
-.secondary,
-.link-button {
- background: transparent;
- color: #0f766e;
-}
-
-.secondary:hover,
-.link-button:hover {
- background: #ccfbf1;
-}
-
-.link-button {
- margin-top: 8px;
- padding-inline: 0;
-}
-
-.actions {
- display: flex;
- justify-content: flex-end;
- gap: 8px;
- margin-top: 22px;
-}
-
-.status {
- min-height: 20px;
- margin: 14px 0 0;
- color: #475569;
- font-size: 13px;
- line-height: 1.5;
-}
-
-.status[data-kind="error"] {
- color: #b91c1c;
-}
-
-.status[data-kind="success"] {
- color: #047857;
-}
-
-.about-links {
- display: flex;
- flex-wrap: wrap;
- gap: 6px;
- margin: 20px 0 0;
- font-size: 12px;
-}
-
-.about-links a {
- color: #0f766e;
-}
-
-.about-links span {
- color: #94a3b8;
-}
-
-.image-save-shell {
- width: min(100%, 420px);
- padding: 22px;
- font-size: 14px;
-}
-
-.image-save-shell h1 {
- margin-bottom: 12px;
- font-size: 18px;
-}
-
-.image-save-shell #host:empty {
- display: none;
-}
-
-.image-save-actions {
- display: grid;
- gap: 8px;
- margin-top: 18px;
-}
-
-.image-save-actions button {
- width: 100%;
-}
diff --git a/apps/extension/src/tweet-save.ts b/apps/extension/src/tweet-save.ts
deleted file mode 100644
index f7f4ce6f..00000000
--- a/apps/extension/src/tweet-save.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import "./styles.css";
-import { localizeDocument, t } from "./i18n";
-
-localizeDocument();
-document.title = t("tweetSaveWindowTitle");
-
-const status = document.querySelector<HTMLParagraphElement>("#status");
-const allowButton = document.querySelector<HTMLButtonElement>("#allow");
-
-const setStatus = (message: string, kind: "normal" | "error" | "success" = "normal") => {
- if (!status) return;
- status.textContent = message;
- status.dataset.kind = kind;
-};
-
-allowButton?.addEventListener("click", () => {
- if (!allowButton) return;
- allowButton.disabled = true;
- void (async () => {
- let granted = false;
- try {
- granted = await chrome.permissions.request({
- origins: ["https://x.com/*", "https://twitter.com/*", "https://mobile.twitter.com/*", "https://www.x.com/*", "https://www.twitter.com/*"],
- });
- } catch {
- granted = false;
- }
- if (!granted) {
- setStatus(t("tweetPermissionDenied"), "error");
- allowButton.disabled = false;
- return;
- }
- try {
- await chrome.runtime.sendMessage({ type: "activateTweetTarget" });
- } catch {
- // The page can still be saved on the next right-click after a reload.
- }
- setStatus(t("tweetPermissionReady"), "success");
- window.setTimeout(() => window.close(), 1600);
- })();
-});
diff --git a/apps/extension/src/ui/clip-feedback.tsx b/apps/extension/src/ui/clip-feedback.tsx
new file mode 100644
index 00000000..cd039f3d
--- /dev/null
+++ b/apps/extension/src/ui/clip-feedback.tsx
@@ -0,0 +1,43 @@
+import { createRoot } from "react-dom/client";
+import { flushSync } from "react-dom";
+import { Toaster, toast } from "sonner";
+
+// Re-injection reuses the mounted component and its Sonner store. Keep both the
+// stylesheet and React tree inside the shadow root, away from the site's CSS.
+declare const __CLIP_FEEDBACK_CSS__: string;
+type Kind = "normal" | "success" | "error";
+const scope = globalThis as typeof globalThis & {
+ __edgeeverImageClipPayload?: { action?: string; message?: string; kind?: string; closeLabel?: string; regionLabel?: string };
+ __edgeeverClipFeedback?: { host: HTMLElement; show: (message: string, kind: Kind) => void; dispose: () => void };
+};
+const payload = scope.__edgeeverImageClipPayload;
+delete scope.__edgeeverImageClipPayload;
+if (payload?.action === "toast") {
+ let service = scope.__edgeeverClipFeedback;
+ if (!service?.host.isConnected) {
+ service?.dispose();
+ const host = document.createElement("div");
+ host.id = "edgeever-clipper-toast";
+ host.style.cssText = "all:initial!important;position:fixed!important;inset:0!important;z-index:2147483647!important;pointer-events:none!important";
+ const shadow = host.attachShadow({ mode: "open" });
+ const style = document.createElement("style");
+ style.textContent = __CLIP_FEEDBACK_CSS__;
+ const mount = document.createElement("div");
+ shadow.append(style, mount);
+ (document.documentElement ?? document.body).appendChild(host);
+ const root = createRoot(mount);
+ flushSync(() => root.render(<Toaster theme="dark" position="bottom-right" offset={16} mobileOffset={16} visibleToasts={1} closeButton hotkey={[]} containerAriaLabel={payload.regionLabel} toastOptions={{ closeButtonAriaLabel: payload.closeLabel, style: { background: "#171717", color: "#fff", border: "1px solid #404040", pointerEvents: "auto" } }} />));
+ service = {
+ host,
+ show(message, kind) {
+ const options = { id: "edgeever-clip", duration: kind === "error" ? 8000 : 4000, style: { background: kind === "error" ? "#b91c1c" : "#171717", color: "#fff", border: "1px solid #404040", pointerEvents: "auto" as const } };
+ if (kind === "error") toast.error(message, options);
+ else if (kind === "success") toast.success(message, options);
+ else toast(message, options);
+ },
+ dispose: () => { root.unmount(); host.remove(); },
+ };
+ scope.__edgeeverClipFeedback = service;
+ }
+ service.show(typeof payload.message === "string" ? payload.message : "", payload.kind === "error" ? "error" : payload.kind === "normal" ? "normal" : "success");
+}
diff --git a/apps/extension/src/ui/main.tsx b/apps/extension/src/ui/main.tsx
new file mode 100644
index 00000000..a8e56fde
--- /dev/null
+++ b/apps/extension/src/ui/main.tsx
@@ -0,0 +1,14 @@
+import { createRoot } from "react-dom/client";
+import { localizeDocument, t } from "../i18n";
+import { Options } from "./options";
+import { Popup } from "./popup";
+import { Permission, type PermissionPage } from "./permission";
+import "./theme.css";
+
+const page = location.pathname.split("/").pop()?.replace(/\.html$/, "") ?? "popup";
+const titles: Record<string, string> = { options: "optionsTitle", popup: "actionTitle", "image-save": "imageSaveWindowTitle", "tweet-save": "tweetSaveWindowTitle", "xhs-save": "xhsSaveWindowTitle", "zhihu-save": "zhihuSaveWindowTitle" };
+localizeDocument();
+document.title = t(titles[page] ?? "actionTitle");
+const root = document.getElementById("root");
+if (!root) throw new Error("Missing extension UI root");
+createRoot(root).render(page === "options" ? <Options /> : page in titles && page !== "popup" ? <Permission page={page as PermissionPage} /> : <Popup />);
diff --git a/apps/extension/src/ui/options.tsx b/apps/extension/src/ui/options.tsx
new file mode 100644
index 00000000..1485fe36
--- /dev/null
+++ b/apps/extension/src/ui/options.tsx
@@ -0,0 +1,109 @@
+import { useEffect, useState, type FormEvent } from "react";
+import { ChevronRight } from "lucide-react";
+import { DEFAULT_SETTINGS, getSettings, saveSettings, testConnection, type ExtensionSettings, type Notebook } from "../extension";
+import { getDiagnosticInfo, diagnosticText, type DiagnosticInfo } from "../diagnostics";
+import { t } from "../i18n";
+import { Button, Input, Status, type Feedback } from "./primitives";
+import { platformGroups } from "./platforms";
+
+const diagnosticFields = [
+ ["extensionVersion", "extensionVersion"], ["manifestVersion", "manifestVersion"], ["browserVersion", "browser"],
+ ["systemVersion", "system"], ["extensionId", "extensionId"], ["instanceOrigin", "instanceOrigin"], ["instancePermission", "instancePermission"],
+] as const;
+const selectStyle = "h-10 w-full rounded-md border border-neutral-300 bg-white px-3 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-500 disabled:opacity-50";
+export function Options() {
+ const [settings, setSettings] = useState<ExtensionSettings>(DEFAULT_SETTINGS);
+ const [ready, setReady] = useState(false);
+ const [notebooks, setNotebooks] = useState<Notebook[]>([]);
+ const [diagnostics, setDiagnostics] = useState<DiagnosticInfo | null>(null);
+ const [busy, setBusy] = useState(false);
+ const [copyBusy, setCopyBusy] = useState(false);
+ const [feedback, setFeedback] = useState<Feedback>({ message: "" });
+ const [copyFeedback, setCopyFeedback] = useState<Feedback>({ message: "" });
+ useEffect(() => {
+ let active = true;
+ void getSettings().then(async value => {
+ if (!active) return;
+ setSettings(value); setReady(true);
+ const info = await getDiagnosticInfo(value);
+ if (active) setDiagnostics(info);
+ }).catch(error => { if (active) setFeedback({ message: error instanceof Error ? error.message : t("settingsSaveFailed"), kind: "error" }); });
+ return () => { active = false; };
+ }, []);
+ const readSettings = () => ({ ...settings, instanceUrl: settings.instanceUrl.trim(), token: settings.token.trim() });
+ async function test() {
+ if (busy || !ready) return;
+ setBusy(true); setFeedback({ message: t("connecting") });
+ try {
+ const value = readSettings();
+ const found = await testConnection(value);
+ setNotebooks(found);
+ // Preserve the saved choice even when the current response omits it.
+ setFeedback({ message: t(found.length === 1 ? "connectionSuccessOne" : "connectionSuccessMany", String(found.length)), kind: "success" });
+ setDiagnostics(await getDiagnosticInfo(value));
+ } catch (error) { setFeedback({ message: error instanceof Error ? error.message : t("connectionFailed"), kind: "error" }); }
+ finally { setBusy(false); }
+ }
+ async function save(event: FormEvent) {
+ event.preventDefault();
+ if (!ready || busy) return;
+ setBusy(true);
+ try {
+ const value = readSettings();
+ await saveSettings(value);
+ setFeedback({ message: t("settingsSaved"), kind: "success" });
+ setDiagnostics(await getDiagnosticInfo(value));
+ } catch (error) { setFeedback({ message: error instanceof Error ? error.message : t("settingsSaveFailed"), kind: "error" }); }
+ finally { setBusy(false); }
+ }
+ async function copy() {
+ setCopyBusy(true);
+ try {
+ const info = await getDiagnosticInfo(readSettings());
+ await navigator.clipboard.writeText(diagnosticText(info));
+ setDiagnostics(info); setCopyFeedback({ message: t("diagnosticsCopied"), kind: "success" });
+ } catch { setCopyFeedback({ message: t("diagnosticsCopyFailed"), kind: "error" }); }
+ finally { setCopyBusy(false); }
+ }
+ const field = (key: keyof ExtensionSettings, value: string) => setSettings(current => ({ ...current, [key]: value }));
+ return <main className="mx-auto max-w-[640px] px-6 py-8">
+ <h1 className="text-[22px] font-semibold">{t("extensionName")}</h1>
+ <form id="settings-form" onSubmit={event => void save(event)} className="mt-6 rounded-xl border border-border bg-card p-4 sm:p-[22px]">
+ <fieldset disabled={!ready || busy} className="space-y-4">
+ <label className="grid gap-2 text-[13px] font-semibold" htmlFor="instance-url">{t("instanceAddress")}<Input id="instance-url" type="url" placeholder="https://notes.example.com" required value={settings.instanceUrl} onChange={event => field("instanceUrl", event.target.value)} /></label>
+ <label className="grid gap-2 text-[13px] font-semibold" htmlFor="token">API Token<Input id="token" type="password" placeholder={t("tokenPlaceholder")} required value={settings.token} onChange={event => field("token", event.target.value)} /></label>
+ <label className="grid gap-2 text-[13px] font-semibold" htmlFor="notebook-id">{t("defaultNotebook")}<select id="notebook-id" className={selectStyle} value={settings.notebookId} onChange={event => field("notebookId", event.target.value)}>
+ <option value="">{t("autoFirstNotebook")}</option>
+ {settings.notebookId && !notebooks.some(book => book.id === settings.notebookId) && <option value={settings.notebookId}>{t("defaultNotebook")}</option>}
+ {notebooks.map(book => <option key={book.id} value={book.id}>{book.name}</option>)}
+ </select></label>
+ <div className="grid grid-cols-2 gap-2 pt-1 min-[400px]:flex min-[400px]:justify-end"><Button id="test" type="button" className="h-auto min-h-9 whitespace-normal" variant="outline" onClick={() => void test()}>{t("testConnection")}</Button><Button id="save" type="submit" className="h-auto min-h-9 whitespace-normal">{t("saveSettings")}</Button></div>
+ </fieldset>
+ <Status {...feedback} busy={busy} />
+ </form>
+ <section aria-labelledby="platforms-title" className="mt-6">
+ <h2 id="platforms-title" className="text-base font-semibold">{t("adaptedPlatformsTitle")}</h2>
+ {platformGroups.map(group => <section key={group.title} aria-labelledby={group.title} className="mt-[18px]">
+ <h3 id={group.title} className="mb-2 text-[13px] font-semibold">{t(group.title)}</h3>
+ <ul className="grid grid-cols-2 gap-x-3 gap-y-2.5 min-[400px]:grid-cols-3 min-[540px]:grid-cols-4">
+ {group.platforms.map(platform => <li key={platform.icon} className="flex min-h-7 min-w-0 items-center gap-2 text-xs"><img src={platform.icon} width={18} height={18} alt="" className="size-[18px] shrink-0 object-contain" /><span className="break-words">{"key" in platform ? t(platform.key) : platform.name}</span></li>)}
+ </ul>
+ </section>)}
+ </section>
+ <section aria-labelledby="diagnostics-title" className="mt-6 border-t border-border pt-5">
+ <h2 id="diagnostics-title" className="text-base font-semibold">{t("diagnosticsTitle")}</h2>
+ <p className="mt-2 mb-3 text-xs text-muted-foreground">{t("extensionVersion")} <span id="extension-version-summary" className="ms-2 font-mono text-neutral-700">{diagnostics?.extensionVersion ?? "—"}</span></p>
+ <details className="group">
+ <summary className="flex cursor-pointer list-none items-center justify-between rounded-lg border border-border bg-card px-3 py-2.5 text-[13px] hover:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-offset-2 [&::-webkit-details-marker]:hidden"><span>{t("viewDiagnostics")}</span><ChevronRight aria-hidden="true" className="size-4 group-open:rotate-90" /></summary>
+ <p className="mt-3 text-xs leading-5 text-muted-foreground">{t("diagnosticsDescription")}</p>
+ <dl className="mt-4 overflow-hidden rounded-lg border border-border bg-card">
+ {diagnosticFields.map(([label, key]) => <div key={key} className="grid grid-cols-[minmax(0,.8fr)_minmax(0,1.2fr)] gap-3 border-b border-neutral-100 px-3 py-2 text-xs last:border-0"><dt className="text-muted-foreground">{t(label)}</dt><dd className="break-all font-mono">{diagnostics?.[key] ?? "—"}</dd></div>)}
+ </dl>
+ <div className="mt-3 flex flex-wrap items-center gap-2"><Button id="copy-diagnostics" type="button" variant="outline" disabled={copyBusy || !ready} onClick={() => void copy()}>{t("copyDiagnostics")}</Button><Status {...copyFeedback} id="copy-status" /></div>
+ </details>
+ </section>
+ <footer className="mt-5 flex flex-wrap gap-1.5 text-xs text-neutral-600">
+ {[["projectAndSource", "https://github.com/tianma-if/edgeever"], ["reportIssue", "https://github.com/tianma-if/edgeever/issues"], ["privacyPolicy", "https://edgeever.org/privacy"]].map(([label, url], index) => <span key={label} className="flex gap-1.5">{index > 0 && <span aria-hidden="true">·</span>}<a href={url} target="_blank" rel="noopener noreferrer" className="underline hover:text-neutral-900 focus-visible:outline-2 focus-visible:outline-offset-2">{t(label)}</a></span>)}
+ </footer>
+ </main>;
+}
diff --git a/apps/extension/src/ui/permission.tsx b/apps/extension/src/ui/permission.tsx
new file mode 100644
index 00000000..64091b17
--- /dev/null
+++ b/apps/extension/src/ui/permission.tsx
@@ -0,0 +1,67 @@
+import { useEffect, useRef, useState } from "react";
+import { t } from "../i18n";
+import { Button, Status, type Feedback } from "./primitives";
+
+const socialPermissions = {
+ "tweet-save": { title: "tweetSaveWindowTitle", intro: "tweetPermissionIntro", allow: "allowTweetAccess", denied: "tweetPermissionDenied", ready: "tweetPermissionReady", message: "activateTweetTarget", origins: ["https://x.com/*", "https://twitter.com/*", "https://mobile.twitter.com/*", "https://www.x.com/*", "https://www.twitter.com/*"] },
+ "xhs-save": { title: "xhsSaveWindowTitle", intro: "xhsPermissionIntro", allow: "allowXhsAccess", denied: "xhsPermissionDenied", ready: "xhsPermissionReady", message: "activateXhsTarget", origins: ["https://www.xiaohongshu.com/*", "https://xiaohongshu.com/*"] },
+ "zhihu-save": { title: "zhihuSaveWindowTitle", intro: "zhihuPermissionIntro", allow: "allowZhihuAccess", denied: "zhihuPermissionDenied", ready: "zhihuPermissionReady", message: "activateZhihuTarget", origins: ["https://www.zhihu.com/*", "https://zhihu.com/*", "https://zhuanlan.zhihu.com/*", "https://www.zhuanlan.zhihu.com/*"] },
+} as const;
+export type PermissionPage = keyof typeof socialPermissions | "image-save";
+type PendingImage = { originPattern: string; host?: string };
+export function Permission({ page }: { page: PermissionPage }) {
+ const config = page === "image-save" ? null : socialPermissions[page];
+ const [pending, setPending] = useState<PendingImage | null>(null);
+ const [busy, setBusy] = useState(false);
+ const [completed, setCompleted] = useState(false);
+ const [feedback, setFeedback] = useState<Feedback>({ message: "" });
+ const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
+ useEffect(() => {
+ let active = true;
+ if (!config) void chrome.runtime.sendMessage({ type: "getPendingImageSave" }).then((value: PendingImage | null) => {
+ if (!active) return;
+ if (value?.originPattern) setPending(value);
+ else setFeedback({ message: t("imageSaveExpired"), kind: "error" });
+ }).catch(() => { if (active) setFeedback({ message: t("imageSaveExpired"), kind: "error" }); });
+ return () => { active = false; if (closeTimer.current) clearTimeout(closeTimer.current); };
+ }, [config]);
+ async function grant(allSites = false) {
+ if (busy || completed || (!config && !pending)) return;
+ setBusy(true); setFeedback({ message: "" });
+ let granted = false;
+ try {
+ // Must execute in this click's user gesture, before any asynchronous work.
+ granted = await chrome.permissions.request({ origins: config ? [...config.origins] : allSites ? ["https://*/*", "http://*/*"] : [pending!.originPattern] });
+ } catch { /* A rejected browser prompt is equivalent to denied access. */ }
+ if (!granted) {
+ setFeedback({ message: t(config?.denied ?? "imagePermissionDenied"), kind: "error" }); setBusy(false); return;
+ }
+ if (config) {
+ try { await chrome.runtime.sendMessage({ type: config.message }); }
+ catch { /* Reload/right-click can still activate the listener after granting. */ }
+ setFeedback({ message: t(config.ready), kind: "success" });
+ } else {
+ setFeedback({ message: t("savingImage") });
+ try {
+ const result = await chrome.runtime.sendMessage({ type: "completePendingImageSave" }) as { ok?: boolean; message?: string } | undefined;
+ if (!result?.ok) throw new Error(result?.message || t("saveFailed"));
+ setFeedback({ message: t("imageSaved"), kind: "success" });
+ } catch (error) {
+ setFeedback({ message: error instanceof Error ? error.message : t("saveFailed"), kind: "error" }); setBusy(false); return;
+ }
+ }
+ setCompleted(true); setBusy(false);
+ closeTimer.current = setTimeout(() => window.close(), config ? 1600 : 700);
+ }
+ const disabled = busy || completed || (!config && !pending);
+ return <main className="mx-auto w-full max-w-[420px] p-[22px]">
+ <h1 className="mb-3 text-lg font-semibold">{t(config?.title ?? "imageSaveWindowTitle")}</h1>
+ <p className="text-[13px] leading-relaxed text-muted-foreground">{t(config?.intro ?? "imagePermissionIntro")}</p>
+ {pending?.host && <p id="host" className="mt-3 text-xs text-muted-foreground">{t("imagePermissionHost", pending.host)}</p>}
+ <div className="mt-[18px] grid gap-2">
+ <Button id="allow" disabled={disabled} className="h-auto min-h-10 whitespace-normal py-2" onClick={() => void grant()}>{t(config?.allow ?? "allowAndSaveImage")}</Button>
+ {!config && <Button id="allow-all" variant="outline" disabled={disabled} className="h-auto min-h-10 whitespace-normal py-2" onClick={() => void grant(true)}>{t("allowAllSitesAndSave")}</Button>}
+ </div>
+ <Status {...feedback} busy={busy} />
+ </main>;
+}
diff --git a/apps/extension/src/ui/platforms.ts b/apps/extension/src/ui/platforms.ts
new file mode 100644
index 00000000..64137279
--- /dev/null
+++ b/apps/extension/src/ui/platforms.ts
@@ -0,0 +1,85 @@
+export const platformGroups = [
+ {
+ "title": "socialPlatformsTitle",
+ "platforms": [
+ {
+ "icon": "/platform-icons/x.svg",
+ "name": "X (Twitter)"
+ },
+ {
+ "icon": "/platform-icons/xiaohongshu.svg",
+ "key": "platformXiaohongshu"
+ },
+ {
+ "icon": "/platform-icons/facebook.svg",
+ "name": "Facebook"
+ },
+ {
+ "icon": "/platform-icons/instagram.svg",
+ "name": "Instagram"
+ },
+ {
+ "icon": "/platform-icons/linkedin.svg",
+ "name": "LinkedIn"
+ },
+ {
+ "icon": "/platform-icons/threads.svg",
+ "name": "Threads"
+ },
+ {
+ "icon": "/platform-icons/bluesky.svg",
+ "name": "Bluesky"
+ }
+ ]
+ },
+ {
+ "title": "readingPlatformsTitle",
+ "platforms": [
+ {
+ "icon": "/platform-icons/zhihu.svg",
+ "key": "platformZhihu"
+ },
+ {
+ "icon": "/platform-icons/reddit.svg",
+ "name": "Reddit"
+ },
+ {
+ "icon": "/platform-icons/github.svg",
+ "name": "GitHub"
+ },
+ {
+ "icon": "/platform-icons/hackernews.svg",
+ "name": "Hacker News"
+ },
+ {
+ "icon": "/platform-icons/v2ex.svg",
+ "name": "V2EX"
+ },
+ {
+ "icon": "/platform-icons/medium.svg",
+ "name": "Medium"
+ },
+ {
+ "icon": "/platform-icons/substack.svg",
+ "name": "Substack"
+ }
+ ]
+ },
+ {
+ "title": "mediaPlatformsTitle",
+ "platforms": [
+ {
+ "icon": "/platform-icons/youtube.svg",
+ "name": "YouTube"
+ },
+ {
+ "icon": "/platform-icons/bilibili.svg",
+ "key": "platformBilibili"
+ },
+ {
+ "icon": "/platform-icons/xiaoyuzhou.png",
+ "key": "platformXiaoyuzhou"
+ }
+ ]
+ }
+] as const;
diff --git a/apps/extension/src/ui/popup.tsx b/apps/extension/src/ui/popup.tsx
new file mode 100644
index 00000000..3f35dae6
--- /dev/null
+++ b/apps/extension/src/ui/popup.tsx
@@ -0,0 +1,43 @@
+import { useEffect, useState } from "react";
+import { Check, Save, Settings } from "lucide-react";
+import { getSettings, type ExtensionSettings } from "../extension";
+import { captureCurrentPage } from "../popup";
+import { t } from "../i18n";
+import { Button, Status, type Feedback } from "./primitives";
+
+type CaptureMode = { kind?: string; platform?: string };
+export function Popup() {
+ const [settings, setSettings] = useState<ExtensionSettings | null>(null);
+ const [mode, setMode] = useState<CaptureMode | null>(null);
+ const [busy, setBusy] = useState(false);
+ const [feedback, setFeedback] = useState<Feedback>({ message: "" });
+ useEffect(() => {
+ let active = true;
+ void getSettings().then(value => { if (active) setSettings(value); }).catch(error => { if (active) setFeedback({ message: error instanceof Error ? error.message : t("saveFailed"), kind: "error" }); });
+ void chrome.runtime.sendMessage({ type: "getCurrentPageCaptureMode" }).then((value: CaptureMode | undefined) => { if (active) setMode(value ?? { kind: "unknown" }); }).catch(() => { if (active) setMode({ kind: "unknown" }); });
+ return () => { active = false; };
+ }, []);
+ const label = !mode ? t("checkingPageCapture") : mode.kind === "unknown" ? t("pageCaptureUnknown")
+ : mode.kind === "unavailable" ? t("pageCaptureUnavailable") : mode.kind === "social-feed" ? t("pageCaptureSelectPost")
+ : mode.platform ? t("pageCaptureAdapted", mode.platform) : t("pageCaptureGeneric");
+ async function save() {
+ if (!settings || busy || mode?.kind === "unavailable") return;
+ setBusy(true);
+ setFeedback({ message: t("readingAndSaving") });
+ try { setFeedback({ message: await captureCurrentPage(settings), kind: "success" }); }
+ catch (error) { setFeedback({ message: error instanceof Error ? error.message : t("saveFailed"), kind: "error" }); }
+ finally { setBusy(false); }
+ }
+ return <main className="w-80 p-5">
+ <header className="flex items-center gap-2.5">
+ <img src="/icons/icon-32.png" width={32} height={32} alt="" className="rounded-lg" />
+ <div><h1 className="text-lg font-semibold leading-tight">EdgeEver</h1><p className="text-xs text-muted-foreground">{t("webClipper")}</p></div>
+ <div id="capture-context" data-kind={mode?.platform ? "adapted" : "generic"} aria-live="polite" aria-label={mode?.platform ? `${mode.platform} · ${label}` : undefined} className="ms-auto flex max-w-28 items-center gap-1 rounded-md bg-neutral-100 px-2 py-1 text-[11px] text-neutral-600">
+ {mode?.platform && <Check aria-hidden="true" className="size-3 shrink-0" />}<span id="capture-mode">{label}</span>
+ </div>
+ </header>
+ <Button id="save" className="mt-6 h-11 w-full gap-2 rounded-lg" disabled={!settings || !mode || busy || mode.kind === "unavailable"} onClick={() => void save()}><Save aria-hidden="true" className="size-4" />{t("saveCurrentPage")}</Button>
+ <Status {...feedback} busy={busy} />
+ <Button id="settings" variant="ghost" className="mt-3 w-full gap-2 text-xs" onClick={() => void chrome.runtime.openOptionsPage()}><Settings aria-hidden="true" className="size-4" />{t("pluginSettings")}</Button>
+ </main>;
+}
diff --git a/apps/extension/src/ui/primitives.tsx b/apps/extension/src/ui/primitives.tsx
new file mode 100644
index 00000000..69c576aa
--- /dev/null
+++ b/apps/extension/src/ui/primitives.tsx
@@ -0,0 +1,16 @@
+import type { ComponentProps } from "react";
+import { CheckCircle2, LoaderCircle, CircleAlert } from "lucide-react";
+import { Button as SharedButton } from "../../../web/src/components/ui/button";
+export { Input } from "../../../web/src/components/ui/input";
+
+export function Button({ variant = "solid", className = "", ...props }: ComponentProps<typeof SharedButton>) {
+ return <SharedButton variant={variant} className={`${variant === "solid" ? "bg-primary text-primary-foreground hover:bg-neutral-800 border-primary" : "border-neutral-300 text-neutral-700 hover:bg-neutral-100 hover:text-neutral-900"} ${className}`} {...props} />;
+}
+
+export type Feedback = { message: string; kind?: "normal" | "success" | "error" };
+export function Status({ message, kind = "normal", busy = false, id = "status" }: Feedback & { busy?: boolean; id?: string }) {
+ const Icon = busy ? LoaderCircle : kind === "success" ? CheckCircle2 : kind === "error" ? CircleAlert : null;
+ return <p id={id} role="status" aria-atomic="true" data-kind={kind} className={`flex items-start gap-2 text-xs leading-5 ${message ? "mt-3" : ""} ${kind === "error" ? "text-red-700" : "text-neutral-600"}`}>
+ {message && Icon && <Icon aria-hidden="true" className={`mt-0.5 size-4 shrink-0 ${busy ? "animate-spin motion-reduce:animate-none" : ""}`} />}{message}
+ </p>;
+}
diff --git a/apps/extension/src/ui/theme.css b/apps/extension/src/ui/theme.css
new file mode 100644
index 00000000..67ae7a69
--- /dev/null
+++ b/apps/extension/src/ui/theme.css
@@ -0,0 +1,24 @@
+@import "tailwindcss" source(none);
+@source "./";
+@source "../../../web/src/components/ui/button.tsx";
+@source "../../../web/src/components/ui/input.tsx";
+@source "../../../web/src/components/ui/button-tooltip.tsx";
+@source "../../../web/src/components/ui/tooltip.tsx";
+
+@theme inline {
+ --color-background: #fafafa;
+ --color-foreground: #171717;
+ --color-card: #fff;
+ --color-primary: #171717;
+ --color-primary-foreground: #fff;
+ --color-muted: #f5f5f5;
+ --color-muted-foreground: #737373;
+ --color-border: #e5e5e5;
+ --color-ring: #262626;
+}
+
+@layer base {
+ body { margin: 0; min-width: 320px; background: var(--color-background); color: var(--color-foreground); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
+ button:not(:disabled), summary { cursor: pointer; }
+ :is(button, input, select, a, summary):focus-visible { outline-color: var(--color-ring); }
+}
diff --git a/apps/extension/src/xhs-save.ts b/apps/extension/src/xhs-save.ts
deleted file mode 100644
index bc536350..00000000
--- a/apps/extension/src/xhs-save.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import "./styles.css";
-import { localizeDocument, t } from "./i18n";
-
-localizeDocument();
-document.title = t("xhsSaveWindowTitle");
-
-const status = document.querySelector<HTMLParagraphElement>("#status");
-const allowButton = document.querySelector<HTMLButtonElement>("#allow");
-
-const setStatus = (message: string, kind: "normal" | "error" | "success" = "normal") => {
- if (!status) return;
- status.textContent = message;
- status.dataset.kind = kind;
-};
-
-allowButton?.addEventListener("click", () => {
- if (!allowButton) return;
- allowButton.disabled = true;
- void (async () => {
- let granted = false;
- try {
- granted = await chrome.permissions.request({
- origins: ["https://www.xiaohongshu.com/*", "https://xiaohongshu.com/*"],
- });
- } catch {
- granted = false;
- }
- if (!granted) {
- setStatus(t("xhsPermissionDenied"), "error");
- allowButton.disabled = false;
- return;
- }
- try {
- await chrome.runtime.sendMessage({ type: "activateXhsTarget" });
- } catch {
- // The page can still be saved on the next right-click after a reload.
- }
- setStatus(t("xhsPermissionReady"), "success");
- window.setTimeout(() => window.close(), 1600);
- })();
-});
diff --git a/apps/extension/src/zhihu-save.ts b/apps/extension/src/zhihu-save.ts
deleted file mode 100644
index 7ac4e571..00000000
--- a/apps/extension/src/zhihu-save.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import "./styles.css";
-import { localizeDocument, t } from "./i18n";
-
-localizeDocument();
-document.title = t("zhihuSaveWindowTitle");
-
-const status = document.querySelector<HTMLParagraphElement>("#status");
-const allowButton = document.querySelector<HTMLButtonElement>("#allow");
-
-const setStatus = (message: string, kind: "normal" | "error" | "success" = "normal") => {
- if (!status) return;
- status.textContent = message;
- status.dataset.kind = kind;
-};
-
-allowButton?.addEventListener("click", () => {
- if (!allowButton) return;
- allowButton.disabled = true;
- void (async () => {
- let granted = false;
- try {
- granted = await chrome.permissions.request({
- origins: [
- "https://www.zhihu.com/*",
- "https://zhihu.com/*",
- "https://zhuanlan.zhihu.com/*",
- "https://www.zhuanlan.zhihu.com/*",
- ],
- });
- } catch {
- granted = false;
- }
- if (!granted) {
- setStatus(t("zhihuPermissionDenied"), "error");
- allowButton.disabled = false;
- return;
- }
- try {
- await chrome.runtime.sendMessage({ type: "activateZhihuTarget" });
- } catch {
- // The page can still be saved on the next right-click after a reload.
- }
- setStatus(t("zhihuPermissionReady"), "success");
- window.setTimeout(() => window.close(), 1600);
- })();
-});
diff --git a/apps/extension/tweet-save.html b/apps/extension/tweet-save.html
index 5d640c0e..b182a3d9 100644
--- a/apps/extension/tweet-save.html
+++ b/apps/extension/tweet-save.html
@@ -3,17 +3,10 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title data-i18n="tweetSaveWindowTitle">Save this post to EdgeEver</title>
+ <title>Save this post to EdgeEver</title>
</head>
<body>
- <main class="image-save-shell">
- <h1 data-i18n="tweetSaveWindowTitle">Save this post to EdgeEver</h1>
- <p class="hint" data-i18n="tweetPermissionIntro">A timeline has many posts. Allow access to X so the clipper can remember the post under the pointer. After that, right-click the same post once more. Only the post you choose is saved to the clipper's default notebook.</p>
- <div class="image-save-actions">
- <button id="allow" type="button" data-i18n="allowTweetAccess">Allow access to X</button>
- </div>
- <p id="status" class="status" role="status"></p>
- </main>
- <script type="module" src="/src/tweet-save.ts"></script>
+ <div id="root"></div>
+ <script type="module" src="/src/ui/main.tsx"></script>
</body>
</html>
diff --git a/apps/extension/vite.config.ts b/apps/extension/vite.config.ts
index 59cf7b0a..fc501226 100644
--- a/apps/extension/vite.config.ts
+++ b/apps/extension/vite.config.ts
@@ -1,16 +1,24 @@
import { fileURLToPath, URL } from "node:url";
+import { readFile } from "node:fs/promises";
+import { createRequire } from "node:module";
import { build as buildStandaloneScript } from "esbuild";
import { defineConfig } from "vite";
+import react from "@vitejs/plugin-react";
+import tailwindcss from "@tailwindcss/vite";
import extensionPackage from "./package.json";
import { buildExtensionManifest, type ExtensionTarget } from "./manifest";
const target: ExtensionTarget = process.env.EDGE_EVER_EXTENSION_TARGET === "firefox"
? "firefox"
: "chromium";
+const require = createRequire(import.meta.url);
export default defineConfig({
root: fileURLToPath(new URL(".", import.meta.url)),
+ resolve: { alias: { "@": fileURLToPath(new URL("../web/src", import.meta.url)) }, dedupe: ["react", "react-dom"] },
plugins: [
+ react(),
+ tailwindcss(),
{
name: "edgeever-extension-manifest",
async generateBundle() {
@@ -39,6 +47,29 @@ export default defineConfig({
source: capture.outputFiles[0].contents,
});
}
+ const feedback = await buildStandaloneScript({
+ entryPoints: [fileURLToPath(new URL("./src/ui/clip-feedback.tsx", import.meta.url))],
+ bundle: true, format: "iife", platform: "browser", target: "es2022", minify: true, write: false,
+ jsx: "automatic",
+ define: {
+ "process.env.NODE_ENV": '"production"',
+ __CLIP_FEEDBACK_CSS__: JSON.stringify(await readFile(require.resolve("sonner/dist/styles.css"), "utf8")),
+ },
+ plugins: [{
+ name: "shadow-only-sonner-styles",
+ setup(build) {
+ build.onLoad({ filter: /sonner[\\/]dist[\\/]index\.(mjs|js)$/ }, async ({ path }) => {
+ // Sonner's default module injects CSS into document.head. The
+ // same published stylesheet is instead mounted in our shadow.
+ const source = await readFile(path, "utf8");
+ const contents = source.replace(/__insertCSS\("(?:\\.|[^"\\])*"\);/g, "");
+ if (contents === source) throw new Error("Sonner CSS injection changed; review shadow isolation before upgrading");
+ return { contents, loader: "js" };
+ });
+ },
+ }],
+ });
+ this.emitFile({ type: "asset", fileName: "assets/clip-feedback.js", source: feedback.outputFiles[0].contents });
},
},
],
@@ -53,6 +84,9 @@ export default defineConfig({
popup: fileURLToPath(new URL("./popup.html", import.meta.url)),
options: fileURLToPath(new URL("./options.html", import.meta.url)),
"image-save": fileURLToPath(new URL("./image-save.html", import.meta.url)),
+ "tweet-save": fileURLToPath(new URL("./tweet-save.html", import.meta.url)),
+ "xhs-save": fileURLToPath(new URL("./xhs-save.html", import.meta.url)),
+ "zhihu-save": fileURLToPath(new URL("./zhihu-save.html", import.meta.url)),
background: fileURLToPath(new URL("./src/background.ts", import.meta.url)),
"capture-image": fileURLToPath(new URL("./src/capture-image.ts", import.meta.url)),
"capture-tweet": fileURLToPath(new URL("./src/capture-tweet.ts", import.meta.url)),
@@ -61,12 +95,9 @@ export default defineConfig({
"capture-zhihu": fileURLToPath(new URL("./src/capture-zhihu.ts", import.meta.url)),
"capture-reddit": fileURLToPath(new URL("./src/capture-reddit.ts", import.meta.url)),
"tweet-target": fileURLToPath(new URL("./src/tweet-target.ts", import.meta.url)),
- "tweet-save": fileURLToPath(new URL("./tweet-save.html", import.meta.url)),
"xhs-target": fileURLToPath(new URL("./src/xhs-target.ts", import.meta.url)),
- "xhs-save": fileURLToPath(new URL("./xhs-save.html", import.meta.url)),
"zhihu-target": fileURLToPath(new URL("./src/zhihu-target.ts", import.meta.url)),
"reddit-target": fileURLToPath(new URL("./src/reddit-target.ts", import.meta.url)),
- "zhihu-save": fileURLToPath(new URL("./zhihu-save.html", import.meta.url)),
},
output: {
entryFileNames: "assets/[name].js",
diff --git a/apps/extension/xhs-save.html b/apps/extension/xhs-save.html
index 51954289..d578b39f 100644
--- a/apps/extension/xhs-save.html
+++ b/apps/extension/xhs-save.html
@@ -3,17 +3,10 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title data-i18n="xhsSaveWindowTitle">Save Xiaohongshu note to EdgeEver</title>
+ <title>Save Xiaohongshu note to EdgeEver</title>
</head>
<body>
- <main class="image-save-shell">
- <h1 data-i18n="xhsSaveWindowTitle">Save Xiaohongshu note to EdgeEver</h1>
- <p class="hint" data-i18n="xhsPermissionIntro">The feed has many notes. Allow access to Xiaohongshu so the clipper can remember the note under the pointer. After that, right-click the same note once more. Only the note you choose is saved to the clipper's default notebook.</p>
- <div class="image-save-actions">
- <button id="allow" type="button" data-i18n="allowXhsAccess">Allow access to Xiaohongshu</button>
- </div>
- <p id="status" class="status" role="status"></p>
- </main>
- <script type="module" src="/src/xhs-save.ts"></script>
+ <div id="root"></div>
+ <script type="module" src="/src/ui/main.tsx"></script>
</body>
</html>
diff --git a/apps/extension/zhihu-save.html b/apps/extension/zhihu-save.html
index 323709ea..a8ad27bb 100644
--- a/apps/extension/zhihu-save.html
+++ b/apps/extension/zhihu-save.html
@@ -3,17 +3,10 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title data-i18n="zhihuSaveWindowTitle">Save Zhihu content to EdgeEver</title>
+ <title>Save Zhihu content to EdgeEver</title>
</head>
<body>
- <main class="image-save-shell">
- <h1 data-i18n="zhihuSaveWindowTitle">Save Zhihu content to EdgeEver</h1>
- <p class="hint" data-i18n="zhihuPermissionIntro">A feed lists many answers and articles. Allow access to Zhihu so the clipper can remember the one under the pointer. After that, right-click the same text once more. Only the answer or article you choose is saved to the clipper's default notebook.</p>
- <div class="image-save-actions">
- <button id="allow" type="button" data-i18n="allowZhihuAccess">Allow access to Zhihu</button>
- </div>
- <p id="status" class="status" role="status"></p>
- </main>
- <script type="module" src="/src/zhihu-save.ts"></script>
+ <div id="root"></div>
+ <script type="module" src="/src/ui/main.tsx"></script>
</body>
</html>
diff --git a/bun.lock b/bun.lock
index a1120651..38ab3fe0 100644
--- a/bun.lock
+++ b/bun.lock
@@ -123,6 +123,9 @@
"@mixmark-io/domino": "2.2.0",
"@mozilla/readability": "^0.6.0",
"marked": "^18.0.5",
+ "react": "~19.2.7",
+ "react-dom": "~19.2.7",
+ "sonner": "2.0.8",
"turndown": "^7.2.4",
},
"devDependencies": {
@@ -3892,6 +3895,8 @@
"sonic-boom": ["[email protected]", "", { "dependencies": { "atomic-sleep": "^1.0.0" } }, "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q=="],
+ "sonner": ["[email protected]", "", { "peerDependencies": { "@types/react": "^18.0.0 || ^19.0.0", "react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc", "react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-UM/ByIoFra8yzV75n1o0Puu0bw5U/9UNnDacrJNspekBewIfsQ3D6ez1nvlWpt7aTsO6rujQtifBpycwIivqlg=="],
+
"source-map": ["[email protected]", "", { "dependencies": { "whatwg-url": "^7.0.0" } }, "sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA=="],
"source-map-js": ["[email protected]", "", {}, "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw=="],