mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
Adds user-controlled auto search functionality for memories across ChatGPT, Claude, and T3.chat with a settings toggle in the extension popup. Changes - Settings UI: Added new "Settings" tab in popup with toggle to enable/disable auto search - Auto Search: Automatically searches user memories while typing in chat apps (disabled by default) - Chat Integration: Supports ChatGPT, Claude, and T3.chat with consistent behavior - User Control: Users can enable/disable auto search via Settings tab - Storage: Added AUTO_SEARCH_ENABLED storage key with default value false Features - ✅ Auto search memories while typing (when enabled) - ✅ Manual search always available via supermemory icons - ✅ Works across all supported chat platforms - ✅ Real-time toggle without requiring page refresh
67 lines
No EOL
1.9 KiB
TypeScript
67 lines
No EOL
1.9 KiB
TypeScript
import { DOMAINS, MESSAGE_TYPES } from "../../utils/constants"
|
|
import { DOMUtils } from "../../utils/ui-components"
|
|
import { initializeChatGPT } from "./chatgpt"
|
|
import { initializeClaude } from "./claude"
|
|
import { saveMemory, setupGlobalKeyboardShortcut, setupStorageListener } from "./shared"
|
|
import { initializeT3 } from "./t3"
|
|
import { handleTwitterNavigation, initializeTwitter, updateTwitterImportUI } from "./twitter"
|
|
|
|
export default defineContentScript({
|
|
matches: ["<all_urls>"],
|
|
main() {
|
|
// Setup global event listeners
|
|
browser.runtime.onMessage.addListener(async (message) => {
|
|
if (message.action === MESSAGE_TYPES.SHOW_TOAST) {
|
|
DOMUtils.showToast(message.state)
|
|
} else if (message.action === MESSAGE_TYPES.SAVE_MEMORY) {
|
|
await saveMemory()
|
|
} else if (message.type === MESSAGE_TYPES.IMPORT_UPDATE) {
|
|
updateTwitterImportUI(message)
|
|
} else if (message.type === MESSAGE_TYPES.IMPORT_DONE) {
|
|
updateTwitterImportUI(message)
|
|
}
|
|
})
|
|
|
|
// Setup global keyboard shortcuts
|
|
setupGlobalKeyboardShortcut()
|
|
|
|
// Setup storage listener
|
|
setupStorageListener()
|
|
|
|
// Observer for dynamic content changes
|
|
const observeForDynamicChanges = () => {
|
|
const observer = new MutationObserver(() => {
|
|
if (DOMUtils.isOnDomain(DOMAINS.CHATGPT)) {
|
|
initializeChatGPT()
|
|
}
|
|
if (DOMUtils.isOnDomain(DOMAINS.CLAUDE)) {
|
|
initializeClaude()
|
|
}
|
|
if (DOMUtils.isOnDomain(DOMAINS.T3)) {
|
|
initializeT3()
|
|
}
|
|
if (DOMUtils.isOnDomain(DOMAINS.TWITTER)) {
|
|
handleTwitterNavigation()
|
|
}
|
|
})
|
|
|
|
observer.observe(document.body, {
|
|
childList: true,
|
|
subtree: true,
|
|
})
|
|
}
|
|
|
|
// Initialize platform-specific functionality
|
|
initializeChatGPT()
|
|
initializeClaude()
|
|
initializeT3()
|
|
initializeTwitter()
|
|
|
|
// Start observing for dynamic changes
|
|
if (document.readyState === "loading") {
|
|
document.addEventListener("DOMContentLoaded", observeForDynamicChanges)
|
|
} else {
|
|
observeForDynamicChanges()
|
|
}
|
|
},
|
|
}) |