From 51ee88121fdb2da686bf5dd6ad95d3ec499ebd9c Mon Sep 17 00:00:00 2001 From: Mahesh Sanikommmu Date: Sun, 19 Oct 2025 15:30:25 -0700 Subject: chore(browser-extension): t3 chat search memories --- apps/browser-extension/entrypoints/content/t3.ts | 54 ++++++++++++------------ apps/browser-extension/wxt.config.ts | 2 +- 2 files changed, 27 insertions(+), 29 deletions(-) (limited to 'apps') diff --git a/apps/browser-extension/entrypoints/content/t3.ts b/apps/browser-extension/entrypoints/content/t3.ts index 4332076e..07a8781f 100644 --- a/apps/browser-extension/entrypoints/content/t3.ts +++ b/apps/browser-extension/entrypoints/content/t3.ts @@ -115,32 +115,35 @@ function setupT3RouteChangeDetection() { function addSupermemoryIconToT3Input() { const targetContainers = document.querySelectorAll( - ".flex.min-w-0.items-center.gap-2.overflow-hidden", + ".flex.min-w-0.items-center.gap-2", ) - targetContainers.forEach((container) => { - if (container.hasAttribute("data-supermemory-icon-added")) { - return - } - - const existingIcon = container.querySelector( - `#${ELEMENT_IDS.T3_INPUT_BAR_ELEMENT}`, - ) - if (existingIcon) { - container.setAttribute("data-supermemory-icon-added", "true") - return - } - - const supermemoryIcon = createT3InputBarElement(async () => { - await getRelatedMemoriesForT3(POSTHOG_EVENT_KEY.T3_CHAT_MEMORIES_SEARCHED) - }) + const container = targetContainers[0] + if (!container) { + return + } - supermemoryIcon.id = `${ELEMENT_IDS.T3_INPUT_BAR_ELEMENT}-${Date.now()}-${Math.random().toString(36).substring(2, 11)}` + if (container.hasAttribute("data-supermemory-icon-added")) { + return + } + const existingIcon = container.querySelector( + `#${ELEMENT_IDS.T3_INPUT_BAR_ELEMENT}`, + ) + if (existingIcon) { container.setAttribute("data-supermemory-icon-added", "true") + return + } - container.insertBefore(supermemoryIcon, container.firstChild) + const supermemoryIcon = createT3InputBarElement(async () => { + await getRelatedMemoriesForT3(POSTHOG_EVENT_KEY.T3_CHAT_MEMORIES_SEARCHED) }) + + supermemoryIcon.id = `${ELEMENT_IDS.T3_INPUT_BAR_ELEMENT}-${Date.now()}-${Math.random().toString(36).substring(2, 11)}` + + container.setAttribute("data-supermemory-icon-added", "true") + + container.insertBefore(supermemoryIcon, container.firstChild) } async function getRelatedMemoriesForT3(actionSource: string) { @@ -150,11 +153,9 @@ async function getRelatedMemoriesForT3(actionSource: string) { const supermemoryContainer = document.querySelector( '[data-supermemory-icon-added="true"]', ) - if ( - supermemoryContainer?.parentElement?.parentElement?.previousElementSibling - ) { + if (supermemoryContainer?.parentElement?.previousElementSibling) { const textareaElement = - supermemoryContainer.parentElement.parentElement.previousElementSibling.querySelector( + supermemoryContainer.parentElement.previousElementSibling.querySelector( "textarea", ) userQuery = textareaElement?.value || "" @@ -220,12 +221,9 @@ async function getRelatedMemoriesForT3(actionSource: string) { const supermemoryContainer = document.querySelector( '[data-supermemory-icon-added="true"]', ) - if ( - supermemoryContainer?.parentElement?.parentElement - ?.previousElementSibling - ) { + if (supermemoryContainer?.parentElement?.previousElementSibling) { textareaElement = - supermemoryContainer.parentElement.parentElement.previousElementSibling.querySelector( + supermemoryContainer.parentElement.previousElementSibling.querySelector( "textarea", ) } diff --git a/apps/browser-extension/wxt.config.ts b/apps/browser-extension/wxt.config.ts index 20435b6c..36c2863e 100644 --- a/apps/browser-extension/wxt.config.ts +++ b/apps/browser-extension/wxt.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ manifest: { name: "supermemory", homepage_url: "https://supermemory.ai", - version: "6.0.100", + version: "6.0.101", permissions: ["contextMenus", "storage", "activeTab", "webRequest", "tabs"], host_permissions: [ "*://x.com/*", -- cgit v1.2.3