Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 0 additions & 69 deletions apps/browser-extension/entrypoints/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from "../utils/api"
import {
CONTAINER_TAGS,
CONTEXT_MENU_IDS,
MESSAGE_TYPES,
POSTHOG_EVENT_KEY,
} from "../utils/constants"
Expand All @@ -26,18 +25,6 @@ export default defineBackground(() => {
let twitterImporter: TwitterImporter | null = null

browser.runtime.onInstalled.addListener(async (details) => {
browser.contextMenus.create({
id: CONTEXT_MENU_IDS.SAVE_TO_SUPERMEMORY,
title: "sync to supermemory",
contexts: ["selection", "page", "link"],
})

browser.contextMenus.create({
id: CONTEXT_MENU_IDS.SEARCH_SUPERMEMORY,
title: "search supermemory",
contexts: ["selection"],
})

if (details.reason === "install") {
await trackEvent("extension_installed", {
reason: details.reason,
Expand All @@ -59,38 +46,6 @@ export default defineBackground(() => {
["requestHeaders", "extraHeaders"],
)

// Handle context menu clicks.
browser.contextMenus.onClicked.addListener(async (info, tab) => {
if (info.menuItemId === CONTEXT_MENU_IDS.SAVE_TO_SUPERMEMORY) {
if (tab?.id) {
try {
await browser.tabs.sendMessage(tab.id, {
action: MESSAGE_TYPES.SAVE_MEMORY,
actionSource: "context_menu",
})
} catch (error) {
console.error("Failed to send message to content script:", error)
}
}
}

if (info.menuItemId === CONTEXT_MENU_IDS.SEARCH_SUPERMEMORY) {
if (tab?.id && info.selectionText) {
try {
await browser.tabs.sendMessage(tab.id, {
action: MESSAGE_TYPES.OPEN_SEARCH_PANEL,
data: info.selectionText,
})
} catch (error) {
console.error(
"Failed to send search message to content script:",
error,
)
}
}
}
})

// Send message to current active tab.
const sendMessageToCurrentTab = async (message: string) => {
const tabs = await browser.tabs.query({
Expand Down Expand Up @@ -319,30 +274,6 @@ export default defineBackground(() => {
return true
}

if (message.action === MESSAGE_TYPES.SEARCH_SELECTION) {
;(async () => {
try {
const query = message.data as string
const responseData = await searchMemories(query)
await trackEvent(POSTHOG_EVENT_KEY.SELECTION_SEARCH_TRIGGERED, {
query_length: query.length,
})
sendResponse({ success: true, data: responseData })
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : "Unknown error"
const isAuthError =
errorMessage.includes("Authentication") ||
errorMessage.includes("token")
sendResponse({
success: false,
error: errorMessage,
isAuthError,
})
}
})()
return true
}
},
)
})
9 changes: 0 additions & 9 deletions apps/browser-extension/entrypoints/content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { DOMAINS, MESSAGE_TYPES } from "../../utils/constants"
import { DOMUtils } from "../../utils/ui-components"
import { initializeChatGPT } from "./chatgpt"
import { initializeClaude } from "./claude"
import {
handleOpenSearchPanel,
initializeSelectionSearch,
} from "./selection-search"
import {
saveMemory,
setupGlobalKeyboardShortcut,
Expand All @@ -28,8 +24,6 @@ export default defineContentScript({
DOMUtils.showToast(message.state)
} else if (message.action === MESSAGE_TYPES.SAVE_MEMORY) {
await saveMemory()
} else if (message.action === MESSAGE_TYPES.OPEN_SEARCH_PANEL) {
handleOpenSearchPanel(message.data as string)
} else if (message.action === MESSAGE_TYPES.TWITTER_IMPORT_OPEN_MODAL) {
await openImportModal()
} else if (message.type === MESSAGE_TYPES.IMPORT_UPDATE) {
Expand Down Expand Up @@ -74,9 +68,6 @@ export default defineContentScript({
initializeT3()
initializeTwitter()

// Initialize universal selection search
initializeSelectionSearch()

// Start observing for dynamic changes
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", observeForDynamicChanges)
Expand Down
Loading
Loading