Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

feat: Chrome Extension + local clip server for one-click web page capture

nash_sub90bbd6038d7
diff --git a/extension/icon128.png b/extension/icon128.png
new file mode 100644
index 00000000..7c65515e
Binary files /dev/null and b/extension/icon128.png differ
diff --git a/extension/icon16.png b/extension/icon16.png
new file mode 100644
index 00000000..ce6948da
Binary files /dev/null and b/extension/icon16.png differ
diff --git a/extension/icon48.png b/extension/icon48.png
new file mode 100644
index 00000000..2bd34553
Binary files /dev/null and b/extension/icon48.png differ
diff --git a/extension/manifest.json b/extension/manifest.json
new file mode 100644
index 00000000..e68fa4cd
--- /dev/null
+++ b/extension/manifest.json
@@ -0,0 +1,21 @@
+{
+ "manifest_version": 3,
+ "name": "LLM Wiki Clipper",
+ "version": "0.1.0",
+ "description": "Clip web pages to your LLM Wiki knowledge base",
+ "permissions": ["activeTab", "scripting"],
+ "host_permissions": ["http://127.0.0.1:19827/*"],
+ "action": {
+ "default_popup": "popup.html",
+ "default_icon": {
+ "16": "icon16.png",
+ "48": "icon48.png",
+ "128": "icon128.png"
+ }
+ },
+ "icons": {
+ "16": "icon16.png",
+ "48": "icon48.png",
+ "128": "icon128.png"
+ }
+}
diff --git a/extension/popup.html b/extension/popup.html
new file mode 100644
index 00000000..4545c675
--- /dev/null
+++ b/extension/popup.html
@@ -0,0 +1,133 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <style>
+ * { margin: 0; padding: 0; box-sizing: border-box; }
+ body {
+ width: 320px;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
+ font-size: 13px;
+ color: #1a1a2e;
+ background: #fafafa;
+ }
+ .header {
+ padding: 12px 16px;
+ background: #1a1a2e;
+ color: white;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+ .header h1 { font-size: 14px; font-weight: 600; }
+ .header .icon { font-size: 18px; }
+ .content { padding: 12px 16px; }
+ .status {
+ padding: 8px 12px;
+ border-radius: 6px;
+ font-size: 12px;
+ margin-bottom: 12px;
+ }
+ .status.connected { background: #ecfdf5; color: #065f46; }
+ .status.disconnected { background: #fef2f2; color: #991b1b; }
+ .status.sending { background: #eff6ff; color: #1e40af; }
+ .status.success { background: #ecfdf5; color: #065f46; }
+ .status.error { background: #fef2f2; color: #991b1b; }
+ .field { margin-bottom: 10px; }
+ .field label {
+ display: block;
+ font-size: 11px;
+ font-weight: 600;
+ color: #6b7280;
+ text-transform: uppercase;
+ margin-bottom: 4px;
+ }
+ .field input, .field textarea {
+ width: 100%;
+ padding: 8px;
+ border: 1px solid #e5e7eb;
+ border-radius: 6px;
+ font-size: 13px;
+ font-family: inherit;
+ outline: none;
+ }
+ .field input:focus, .field textarea:focus {
+ border-color: #6366f1;
+ box-shadow: 0 0 0 2px rgba(99,102,241,0.1);
+ }
+ .field textarea { resize: vertical; min-height: 60px; }
+ .preview {
+ padding: 8px;
+ background: #f3f4f6;
+ border-radius: 6px;
+ font-size: 11px;
+ color: #6b7280;
+ max-height: 80px;
+ overflow-y: auto;
+ white-space: pre-wrap;
+ word-break: break-all;
+ }
+ .btn {
+ width: 100%;
+ padding: 10px;
+ border: none;
+ border-radius: 6px;
+ font-size: 13px;
+ font-weight: 600;
+ cursor: pointer;
+ transition: all 0.15s;
+ }
+ .btn-primary {
+ background: #4f46e5;
+ color: white;
+ }
+ .btn-primary:hover { background: #4338ca; }
+ .btn-primary:disabled {
+ background: #9ca3af;
+ cursor: not-allowed;
+ }
+ .footer {
+ padding: 8px 16px;
+ border-top: 1px solid #e5e7eb;
+ font-size: 10px;
+ color: #9ca3af;
+ text-align: center;
+ }
+ </style>
+</head>
+<body>
+ <div class="header">
+ <span class="icon">📚</span>
+ <h1>LLM Wiki Clipper</h1>
+ </div>
+
+ <div class="content">
+ <div id="statusBar" class="status disconnected">Checking connection...</div>
+
+ <div class="field">
+ <label>Title</label>
+ <input type="text" id="titleInput" placeholder="Page title">
+ </div>
+
+ <div class="field">
+ <label>URL</label>
+ <div class="preview" id="urlPreview">—</div>
+ </div>
+
+ <div class="field">
+ <label>Content Preview</label>
+ <div class="preview" id="contentPreview">Extracting content...</div>
+ </div>
+
+ <button class="btn btn-primary" id="clipBtn" disabled>
+ 📎 Clip to Wiki
+ </button>
+ </div>
+
+ <div class="footer">
+ Content will be saved to your LLM Wiki project
+ </div>
+
+ <script src="popup.js"></script>
+</body>
+</html>
diff --git a/extension/popup.js b/extension/popup.js
new file mode 100644
index 00000000..a0c453e3
--- /dev/null
+++ b/extension/popup.js
@@ -0,0 +1,191 @@
+const API_URL = "http://127.0.0.1:19827";
+
+const statusBar = document.getElementById("statusBar");
+const titleInput = document.getElementById("titleInput");
+const urlPreview = document.getElementById("urlPreview");
+const contentPreview = document.getElementById("contentPreview");
+const clipBtn = document.getElementById("clipBtn");
+
+let extractedContent = "";
+let pageUrl = "";
+
+// Check if LLM Wiki app is running
+async function checkConnection() {
+ try {
+ const res = await fetch(`${API_URL}/status`, { method: "GET" });
+ const data = await res.json();
+ if (data.ok) {
+ statusBar.className = "status connected";
+ statusBar.textContent = "✓ Connected to LLM Wiki";
+ return true;
+ }
+ } catch {
+ // not running
+ }
+ statusBar.className = "status disconnected";
+ statusBar.textContent = "✗ LLM Wiki app is not running";
+ clipBtn.disabled = true;
+ return false;
+}
+
+// Extract content from current tab
+async function extractContent() {
+ try {
+ const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
+ if (!tab?.id) return;
+
+ pageUrl = tab.url || "";
+ titleInput.value = tab.title || "Untitled";
+ urlPreview.textContent = pageUrl;
+
+ // Inject content extraction script
+ const results = await chrome.scripting.executeScript({
+ target: { tabId: tab.id },
+ func: () => {
+ // Try to get article content using common selectors
+ const selectors = [
+ "article",
+ '[role="main"]',
+ "main",
+ ".post-content",
+ ".article-content",
+ ".entry-content",
+ "#content",
+ ".content",
+ ];
+
+ let article = null;
+ for (const sel of selectors) {
+ article = document.querySelector(sel);
+ if (article) break;
+ }
+
+ // Fallback to body
+ if (!article) {
+ article = document.body;
+ }
+
+ // Clone to avoid modifying the page
+ const clone = article.cloneNode(true);
+
+ // Remove unwanted elements
+ const removeSelectors = [
+ "script", "style", "nav", "header", "footer",
+ ".sidebar", ".nav", ".menu", ".ad", ".advertisement",
+ ".comments", ".comment", "#comments", ".social-share",
+ ".related-posts", ".newsletter", "[role='navigation']",
+ ];
+ for (const sel of removeSelectors) {
+ clone.querySelectorAll(sel).forEach((el) => el.remove());
+ }
+
+ // Convert to simplified markdown-like text
+ function nodeToText(node, depth = 0) {
+ if (node.nodeType === Node.TEXT_NODE) {
+ return node.textContent.trim();
+ }
+ if (node.nodeType !== Node.ELEMENT_NODE) return "";
+
+ const tag = node.tagName.toLowerCase();
+ const children = Array.from(node.childNodes)
+ .map((c) => nodeToText(c, depth))
+ .filter((t) => t)
+ .join(" ");
+
+ if (!children.trim()) return "";
+
+ switch (tag) {
+ case "h1": return `\n\n# ${children}\n\n`;
+ case "h2": return `\n\n## ${children}\n\n`;
+ case "h3": return `\n\n### ${children}\n\n`;
+ case "h4": return `\n\n#### ${children}\n\n`;
+ case "p": return `\n\n${children}\n\n`;
+ case "li": return `\n- ${children}`;
+ case "ul": case "ol": return `\n${children}\n`;
+ case "blockquote": return `\n\n> ${children}\n\n`;
+ case "pre": case "code": return `\n\n\`\`\`\n${children}\n\`\`\`\n\n`;
+ case "strong": case "b": return `**${children}**`;
+ case "em": case "i": return `*${children}*`;
+ case "a": {
+ const href = node.getAttribute("href") || "";
+ return `[${children}](${href})`;
+ }
+ case "img": {
+ const alt = node.getAttribute("alt") || "image";
+ const src = node.getAttribute("src") || "";
+ return `\n\n![${alt}](${src})\n\n`;
+ }
+ case "br": return "\n";
+ case "hr": return "\n\n---\n\n";
+ case "table": return `\n\n${children}\n\n`;
+ case "tr": return `| ${children} |\n`;
+ case "th": case "td": return ` ${children} |`;
+ default: return children;
+ }
+ }
+
+ let text = nodeToText(clone);
+ // Clean up excessive whitespace
+ text = text.replace(/\n{3,}/g, "\n\n").trim();
+ return text;
+ },
+ });
+
+ if (results && results[0] && results[0].result) {
+ extractedContent = results[0].result;
+ const preview = extractedContent.slice(0, 200);
+ contentPreview.textContent = preview + (extractedContent.length > 200 ? "..." : "");
+ clipBtn.disabled = false;
+ } else {
+ contentPreview.textContent = "Failed to extract content";
+ }
+ } catch (err) {
+ contentPreview.textContent = `Error: ${err.message}`;
+ }
+}
+
+// Send clip to LLM Wiki
+async function sendClip() {
+ clipBtn.disabled = true;
+ statusBar.className = "status sending";
+ statusBar.textContent = "⏳ Sending to LLM Wiki...";
+
+ try {
+ const res = await fetch(`${API_URL}/clip`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ title: titleInput.value,
+ url: pageUrl,
+ content: extractedContent,
+ }),
+ });
+
+ const data = await res.json();
+
+ if (data.ok) {
+ statusBar.className = "status success";
+ statusBar.textContent = `✓ Saved: ${data.path}`;
+ clipBtn.textContent = "✓ Clipped!";
+ clipBtn.disabled = true;
+ } else {
+ statusBar.className = "status error";
+ statusBar.textContent = `✗ Error: ${data.error}`;
+ clipBtn.disabled = false;
+ }
+ } catch (err) {
+ statusBar.className = "status error";
+ statusBar.textContent = `✗ Connection failed: ${err.message}`;
+ clipBtn.disabled = false;
+ }
+}
+
+clipBtn.addEventListener("click", sendClip);
+
+// Initialize
+(async () => {
+ const connected = await checkConnection();
+ if (connected) {
+ await extractContent();
+ }
+})();