mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-07 08:26:15 +00:00
fix(browser-extension): resolve Biome lint and format issues
- Remove dead code after return statements in chatgpt.ts and claude.ts - Replace forEach callbacks that return values with for...of loops - Prefix unused function with underscore (appendStoredMemories) - Apply formatting fixes to all changed files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3e9391b451
commit
07c91db0e4
7 changed files with 70 additions and 505 deletions
|
|
@ -208,10 +208,7 @@ async function getRelatedMemoriesForChatGPT(actionSource: string) {
|
|||
promptElement,
|
||||
response.data,
|
||||
)
|
||||
console.log(
|
||||
"Prompt element dataset:",
|
||||
memoryText,
|
||||
)
|
||||
console.log("Prompt element dataset:", memoryText)
|
||||
|
||||
iconElement.dataset.memoriesData = String(response.data)
|
||||
|
||||
|
|
@ -387,220 +384,6 @@ function updateChatGPTIconFeedback(
|
|||
message.toLowerCase().includes("error") ? "error" : "none",
|
||||
)
|
||||
showMarkerPopover(iconElement, message, undefined, fallbackReset)
|
||||
return
|
||||
|
||||
if (!iconElement.dataset.originalHtml) {
|
||||
iconElement.dataset.originalHtml = iconElement.innerHTML
|
||||
}
|
||||
|
||||
const feedbackDiv = document.createElement("div")
|
||||
feedbackDiv.style.cssText = `
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 4px 8px;
|
||||
background: #513EA9;
|
||||
border-radius: 12px;
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
cursor: ${message === "Included Memories" ? "pointer" : "default"};
|
||||
position: relative;
|
||||
`
|
||||
|
||||
feedbackDiv.innerHTML = `
|
||||
<span>✓</span>
|
||||
<span>${message}</span>
|
||||
`
|
||||
|
||||
if (message === "Included Memories" && iconElement.dataset.memoriesData) {
|
||||
const popup = document.createElement("div")
|
||||
popup.style.cssText = `
|
||||
position: fixed;
|
||||
bottom: 80px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: #1a1a1a;
|
||||
color: white;
|
||||
padding: 0;
|
||||
border-radius: 12px;
|
||||
font-size: 13px;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
|
||||
max-width: 500px;
|
||||
max-height: 400px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
z-index: 999999;
|
||||
display: none;
|
||||
border: 1px solid #333;
|
||||
`
|
||||
|
||||
const header = document.createElement("div")
|
||||
header.style.cssText = `
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px;
|
||||
border-bottom: 1px solid #333;
|
||||
opacity: 0.8;
|
||||
`
|
||||
header.innerHTML = `
|
||||
<span style="font-weight: 600; color: #fff;">Included Memories</span>
|
||||
`
|
||||
|
||||
const content = document.createElement("div")
|
||||
content.style.cssText = `
|
||||
padding: 0;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
`
|
||||
|
||||
const memoriesText = iconElement.dataset.memoriesData || ""
|
||||
console.log("Memories text:", memoriesText)
|
||||
const individualMemories = memoriesText
|
||||
.split(/[,\n]/)
|
||||
.map((memory) => memory.trim())
|
||||
.filter((memory) => memory.length > 0 && memory !== ",")
|
||||
console.log("Individual memories:", individualMemories)
|
||||
|
||||
individualMemories.forEach((memory, index) => {
|
||||
const memoryItem = document.createElement("div")
|
||||
memoryItem.style.cssText = `
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 10px;
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
`
|
||||
|
||||
const memoryText = document.createElement("div")
|
||||
memoryText.style.cssText = `
|
||||
flex: 1;
|
||||
color: #e5e5e5;
|
||||
`
|
||||
memoryText.textContent = memory.trim()
|
||||
|
||||
const removeBtn = document.createElement("button")
|
||||
removeBtn.style.cssText = `
|
||||
background: transparent;
|
||||
color: #9ca3af;
|
||||
border: none;
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
height: fit-content;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
`
|
||||
removeBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`
|
||||
removeBtn.dataset.memoryIndex = index.toString()
|
||||
|
||||
removeBtn.addEventListener("mouseenter", () => {
|
||||
removeBtn.style.color = "#ef4444"
|
||||
})
|
||||
removeBtn.addEventListener("mouseleave", () => {
|
||||
removeBtn.style.color = "#9ca3af"
|
||||
})
|
||||
|
||||
memoryItem.appendChild(memoryText)
|
||||
memoryItem.appendChild(removeBtn)
|
||||
content.appendChild(memoryItem)
|
||||
})
|
||||
|
||||
popup.appendChild(header)
|
||||
popup.appendChild(content)
|
||||
document.body.appendChild(popup)
|
||||
|
||||
feedbackDiv.addEventListener("mouseenter", () => {
|
||||
const textSpan = feedbackDiv.querySelector("span:last-child")
|
||||
if (textSpan) {
|
||||
textSpan.textContent = "Click to see memories"
|
||||
}
|
||||
})
|
||||
|
||||
feedbackDiv.addEventListener("mouseleave", () => {
|
||||
const textSpan = feedbackDiv.querySelector("span:last-child")
|
||||
if (textSpan) {
|
||||
textSpan.textContent = "Included Memories"
|
||||
}
|
||||
})
|
||||
|
||||
feedbackDiv.addEventListener("click", (e) => {
|
||||
e.stopPropagation()
|
||||
popup.style.display = "block"
|
||||
})
|
||||
|
||||
document.addEventListener("click", (e) => {
|
||||
if (!popup.contains(e.target as Node)) {
|
||||
popup.style.display = "none"
|
||||
}
|
||||
})
|
||||
|
||||
content.querySelectorAll("button[data-memory-index]").forEach((button) => {
|
||||
const htmlButton = button as HTMLButtonElement
|
||||
htmlButton.addEventListener("click", () => {
|
||||
const index = Number.parseInt(htmlButton.dataset.memoryIndex || "0", 10)
|
||||
const memoryItem = htmlButton.parentElement
|
||||
|
||||
if (memoryItem) {
|
||||
content.removeChild(memoryItem)
|
||||
}
|
||||
|
||||
const currentMemories = (iconElement.dataset.memoriesData || "")
|
||||
.split(/[,\n]/)
|
||||
.map((memory) => memory.trim())
|
||||
.filter((memory) => memory.length > 0 && memory !== ",")
|
||||
currentMemories.splice(index, 1)
|
||||
|
||||
const updatedMemories = currentMemories.join(" ,")
|
||||
|
||||
iconElement.dataset.memoriesData = updatedMemories
|
||||
|
||||
const promptElement = document.getElementById("prompt-textarea")
|
||||
if (promptElement) {
|
||||
promptElement.dataset.supermemories = `\n\nSupermemories of user (only for the reference): ${updatedMemories}`
|
||||
}
|
||||
|
||||
content
|
||||
.querySelectorAll("button[data-memory-index]")
|
||||
.forEach((btn, newIndex) => {
|
||||
const htmlBtn = btn as HTMLButtonElement
|
||||
htmlBtn.dataset.memoryIndex = newIndex.toString()
|
||||
})
|
||||
|
||||
if (currentMemories.length <= 1) {
|
||||
if (promptElement?.dataset.supermemories) {
|
||||
delete promptElement.dataset.supermemories
|
||||
delete iconElement.dataset.memoriesData
|
||||
iconElement.innerHTML = iconElement.dataset.originalHtml || ""
|
||||
delete iconElement.dataset.originalHtml
|
||||
}
|
||||
popup.style.display = "none"
|
||||
if (document.body.contains(popup)) {
|
||||
document.body.removeChild(popup)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
if (document.body.contains(popup)) {
|
||||
document.body.removeChild(popup)
|
||||
}
|
||||
}, 300000)
|
||||
}
|
||||
|
||||
iconElement.innerHTML = ""
|
||||
iconElement.appendChild(feedbackDiv)
|
||||
|
||||
if (resetAfter > 0) {
|
||||
setTimeout(() => {
|
||||
iconElement.innerHTML = iconElement.dataset.originalHtml || ""
|
||||
delete iconElement.dataset.originalHtml
|
||||
}, resetAfter)
|
||||
}
|
||||
}
|
||||
|
||||
function addSaveChatGPTElementBeforeComposerBtn() {
|
||||
|
|
@ -623,7 +406,9 @@ function addSaveChatGPTElementBeforeComposerBtn() {
|
|||
)
|
||||
if (existingMarkers.length > 1) {
|
||||
debugChatGPT("removed duplicate markers", existingMarkers.length)
|
||||
existingMarkers.forEach((marker) => marker.remove())
|
||||
for (const marker of existingMarkers) {
|
||||
marker.remove()
|
||||
}
|
||||
} else if (existingMarkers.length === 1) {
|
||||
debugChatGPT("marker already exists")
|
||||
return
|
||||
|
|
@ -642,7 +427,8 @@ function addSaveChatGPTElementBeforeComposerBtn() {
|
|||
const micButton = buttons.find((button) => isChatGPTMicButton(button))
|
||||
const voiceButton = buttons.find((button) => isChatGPTVoiceButton(button))
|
||||
const sendButton = buttons.find((button) => isChatGPTSendButton(button))
|
||||
const anchorButton = micButton || voiceButton || sendButton || buttons[buttons.length - 1]
|
||||
const anchorButton =
|
||||
micButton || voiceButton || sendButton || buttons[buttons.length - 1]
|
||||
const anchorSlot = findChatGPTButtonSlot(anchorButton, composer)
|
||||
const speechContainer = composer.querySelector(
|
||||
'[data-testid="composer-speech-button-container"]',
|
||||
|
|
@ -721,8 +507,9 @@ function findChatGPTComposerButtons(
|
|||
return allButtons.filter((button) => {
|
||||
const rect = button.getBoundingClientRect()
|
||||
const verticallyNear =
|
||||
Math.abs(rect.top + rect.height / 2 - (inputRect.top + inputRect.height / 2)) <
|
||||
120
|
||||
Math.abs(
|
||||
rect.top + rect.height / 2 - (inputRect.top + inputRect.height / 2),
|
||||
) < 120
|
||||
const horizontallyNear =
|
||||
rect.left > inputRect.left - 80 && rect.left < inputRect.right + 260
|
||||
|
||||
|
|
@ -788,11 +575,7 @@ function describeElement(element: Element | null): string | null {
|
|||
if (element.id) parts.push(`#${element.id}`)
|
||||
if (element.className && typeof element.className === "string") {
|
||||
parts.push(
|
||||
`.${element.className
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.slice(0, 4)
|
||||
.join(".")}`,
|
||||
`.${element.className.trim().split(/\s+/).slice(0, 4).join(".")}`,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -842,7 +625,9 @@ async function setupChatGPTAutoFetch() {
|
|||
if (content.length === 0) {
|
||||
clearMemorySuggestion("chatgpt", promptTextarea)
|
||||
document
|
||||
.querySelectorAll('[id*="sm-chatgpt-input-bar-element-before-composer"]')
|
||||
.querySelectorAll(
|
||||
'[id*="sm-chatgpt-input-bar-element-before-composer"]',
|
||||
)
|
||||
.forEach((icon) => {
|
||||
setMemoryMarkerStatus(icon as HTMLElement, "neutral")
|
||||
})
|
||||
|
|
|
|||
|
|
@ -172,11 +172,15 @@ function addSupermemoryIconToClaudeInput() {
|
|||
}
|
||||
|
||||
const existingMarkers = Array.from(
|
||||
document.querySelectorAll(`[id*="${ELEMENT_IDS.CLAUDE_INPUT_BAR_ELEMENT}"]`),
|
||||
document.querySelectorAll(
|
||||
`[id*="${ELEMENT_IDS.CLAUDE_INPUT_BAR_ELEMENT}"]`,
|
||||
),
|
||||
)
|
||||
if (existingMarkers.length > 1) {
|
||||
debugClaude("removed duplicate markers", existingMarkers.length)
|
||||
existingMarkers.forEach((marker) => marker.remove())
|
||||
for (const marker of existingMarkers) {
|
||||
marker.remove()
|
||||
}
|
||||
} else if (existingMarkers.length === 1) {
|
||||
debugClaude("marker already exists")
|
||||
return
|
||||
|
|
@ -192,12 +196,11 @@ function addSupermemoryIconToClaudeInput() {
|
|||
})),
|
||||
})
|
||||
|
||||
const micButton = buttons.find((button) =>
|
||||
isClaudeMicButton(button),
|
||||
)
|
||||
const micButton = buttons.find((button) => isClaudeMicButton(button))
|
||||
const voiceButton = buttons.find((button) => isClaudeVoiceButton(button))
|
||||
const sendButton = buttons.find((button) => isClaudeSendButton(button))
|
||||
const anchorButton = micButton || voiceButton || sendButton || buttons[buttons.length - 1]
|
||||
const anchorButton =
|
||||
micButton || voiceButton || sendButton || buttons[buttons.length - 1]
|
||||
const anchorSlot = findClaudeButtonSlot(anchorButton, composer)
|
||||
const targetContainer = anchorSlot?.parentElement || input.parentElement
|
||||
|
||||
|
|
@ -277,8 +280,9 @@ function findClaudeComposerButtons(
|
|||
return allButtons.filter((button) => {
|
||||
const rect = button.getBoundingClientRect()
|
||||
const verticallyNear =
|
||||
Math.abs(rect.top + rect.height / 2 - (inputRect.top + inputRect.height / 2)) <
|
||||
120
|
||||
Math.abs(
|
||||
rect.top + rect.height / 2 - (inputRect.top + inputRect.height / 2),
|
||||
) < 120
|
||||
const horizontallyNear =
|
||||
rect.left > inputRect.left - 80 && rect.left < inputRect.right + 260
|
||||
|
||||
|
|
@ -330,11 +334,7 @@ function describeElement(element: Element | null): string | null {
|
|||
if (element.id) parts.push(`#${element.id}`)
|
||||
if (element.className && typeof element.className === "string") {
|
||||
parts.push(
|
||||
`.${element.className
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.slice(0, 4)
|
||||
.join(".")}`,
|
||||
`.${element.className.trim().split(/\s+/).slice(0, 4).join(".")}`,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -451,10 +451,7 @@ async function getRelatedMemoriesForClaude(actionSource: string) {
|
|||
textareaElement,
|
||||
response.data,
|
||||
)
|
||||
console.log(
|
||||
"Text element dataset:",
|
||||
memoryText,
|
||||
)
|
||||
console.log("Text element dataset:", memoryText)
|
||||
|
||||
iconElement.dataset.memoriesData = String(response.data)
|
||||
|
||||
|
|
@ -712,222 +709,6 @@ function updateClaudeIconFeedback(
|
|||
message.toLowerCase().includes("error") ? "error" : "none",
|
||||
)
|
||||
showMarkerPopover(iconElement, message, undefined, fallbackReset)
|
||||
return
|
||||
|
||||
if (!iconElement.dataset.originalHtml) {
|
||||
iconElement.dataset.originalHtml = iconElement.innerHTML
|
||||
}
|
||||
|
||||
const feedbackDiv = document.createElement("div")
|
||||
feedbackDiv.style.cssText = `
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 8px;
|
||||
background: #513EA9;
|
||||
border-radius: 6px;
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
cursor: ${message === "Included Memories" ? "pointer" : "default"};
|
||||
position: relative;
|
||||
`
|
||||
|
||||
feedbackDiv.innerHTML = `
|
||||
<span>✓</span>
|
||||
<span>${message}</span>
|
||||
`
|
||||
|
||||
if (message === "Included Memories" && iconElement.dataset.memoriesData) {
|
||||
const popup = document.createElement("div")
|
||||
popup.style.cssText = `
|
||||
position: fixed;
|
||||
bottom: 80px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: #1a1a1a;
|
||||
color: white;
|
||||
padding: 0;
|
||||
border-radius: 12px;
|
||||
font-size: 13px;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
|
||||
max-width: 500px;
|
||||
max-height: 400px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
z-index: 999999;
|
||||
display: none;
|
||||
border: 1px solid #333;
|
||||
`
|
||||
|
||||
const header = document.createElement("div")
|
||||
header.style.cssText = `
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px;
|
||||
border-bottom: 1px solid #333;
|
||||
opacity: 0.8;
|
||||
`
|
||||
header.innerHTML = `
|
||||
<span style="font-weight: 600; color: #fff;">Included Memories</span>
|
||||
`
|
||||
|
||||
const content = document.createElement("div")
|
||||
content.style.cssText = `
|
||||
padding: 0;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
`
|
||||
|
||||
const memoriesText = iconElement.dataset.memoriesData || ""
|
||||
console.log("Memories text:", memoriesText)
|
||||
const individualMemories = memoriesText
|
||||
.split(/[,\n]/)
|
||||
.map((memory) => memory.trim())
|
||||
.filter((memory) => memory.length > 0 && memory !== ",")
|
||||
console.log("Individual memories:", individualMemories)
|
||||
|
||||
individualMemories.forEach((memory, index) => {
|
||||
const memoryItem = document.createElement("div")
|
||||
memoryItem.style.cssText = `
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 10px;
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
`
|
||||
|
||||
const memoryText = document.createElement("div")
|
||||
memoryText.style.cssText = `
|
||||
flex: 1;
|
||||
color: #e5e5e5;
|
||||
`
|
||||
memoryText.textContent = memory.trim()
|
||||
|
||||
const removeBtn = document.createElement("button")
|
||||
removeBtn.style.cssText = `
|
||||
background: transparent;
|
||||
color: #9ca3af;
|
||||
border: none;
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
height: fit-content;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
`
|
||||
removeBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`
|
||||
removeBtn.dataset.memoryIndex = index.toString()
|
||||
|
||||
removeBtn.addEventListener("mouseenter", () => {
|
||||
removeBtn.style.color = "#ef4444"
|
||||
})
|
||||
removeBtn.addEventListener("mouseleave", () => {
|
||||
removeBtn.style.color = "#9ca3af"
|
||||
})
|
||||
|
||||
memoryItem.appendChild(memoryText)
|
||||
memoryItem.appendChild(removeBtn)
|
||||
content.appendChild(memoryItem)
|
||||
})
|
||||
|
||||
popup.appendChild(header)
|
||||
popup.appendChild(content)
|
||||
document.body.appendChild(popup)
|
||||
|
||||
feedbackDiv.addEventListener("mouseenter", () => {
|
||||
const textSpan = feedbackDiv.querySelector("span:last-child")
|
||||
if (textSpan) {
|
||||
textSpan.textContent = "Click to see memories"
|
||||
}
|
||||
})
|
||||
|
||||
feedbackDiv.addEventListener("mouseleave", () => {
|
||||
const textSpan = feedbackDiv.querySelector("span:last-child")
|
||||
if (textSpan) {
|
||||
textSpan.textContent = "Included Memories"
|
||||
}
|
||||
})
|
||||
|
||||
feedbackDiv.addEventListener("click", (e) => {
|
||||
e.stopPropagation()
|
||||
popup.style.display = "block"
|
||||
})
|
||||
|
||||
document.addEventListener("click", (e) => {
|
||||
if (!popup.contains(e.target as Node)) {
|
||||
popup.style.display = "none"
|
||||
}
|
||||
})
|
||||
|
||||
content.querySelectorAll("button[data-memory-index]").forEach((button) => {
|
||||
const htmlButton = button as HTMLButtonElement
|
||||
htmlButton.addEventListener("click", () => {
|
||||
const index = Number.parseInt(htmlButton.dataset.memoryIndex || "0", 10)
|
||||
const memoryItem = htmlButton.parentElement
|
||||
|
||||
if (memoryItem) {
|
||||
content.removeChild(memoryItem)
|
||||
}
|
||||
|
||||
const currentMemories = (iconElement.dataset.memoriesData || "")
|
||||
.split(/[,\n]/)
|
||||
.map((memory) => memory.trim())
|
||||
.filter((memory) => memory.length > 0 && memory !== ",")
|
||||
currentMemories.splice(index, 1)
|
||||
|
||||
const updatedMemories = currentMemories.join(" ,")
|
||||
|
||||
iconElement.dataset.memoriesData = updatedMemories
|
||||
|
||||
const textareaElement = document.querySelector(
|
||||
'div[contenteditable="true"]',
|
||||
) as HTMLElement
|
||||
if (textareaElement) {
|
||||
textareaElement.dataset.supermemories = `\n\nSupermemories of user (only for the reference): ${updatedMemories}`
|
||||
}
|
||||
|
||||
content
|
||||
.querySelectorAll("button[data-memory-index]")
|
||||
.forEach((btn, newIndex) => {
|
||||
const htmlBtn = btn as HTMLButtonElement
|
||||
htmlBtn.dataset.memoryIndex = newIndex.toString()
|
||||
})
|
||||
|
||||
if (currentMemories.length <= 1) {
|
||||
if (textareaElement?.dataset.supermemories) {
|
||||
delete textareaElement.dataset.supermemories
|
||||
delete iconElement.dataset.memoriesData
|
||||
iconElement.innerHTML = iconElement.dataset.originalHtml || ""
|
||||
delete iconElement.dataset.originalHtml
|
||||
}
|
||||
popup.style.display = "none"
|
||||
if (document.body.contains(popup)) {
|
||||
document.body.removeChild(popup)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
if (document.body.contains(popup)) {
|
||||
document.body.removeChild(popup)
|
||||
}
|
||||
}, 300000)
|
||||
}
|
||||
|
||||
iconElement.innerHTML = ""
|
||||
iconElement.appendChild(feedbackDiv)
|
||||
|
||||
if (resetAfter > 0) {
|
||||
setTimeout(() => {
|
||||
iconElement.innerHTML = iconElement.dataset.originalHtml || ""
|
||||
delete iconElement.dataset.originalHtml
|
||||
}, resetAfter)
|
||||
}
|
||||
}
|
||||
|
||||
function setupClaudePromptCapture() {
|
||||
|
|
|
|||
|
|
@ -160,11 +160,15 @@ function addSupermemoryIconToGeminiInput() {
|
|||
}
|
||||
|
||||
const existingMarkers = Array.from(
|
||||
document.querySelectorAll(`[id*="${ELEMENT_IDS.GEMINI_INPUT_BAR_ELEMENT}"]`),
|
||||
document.querySelectorAll(
|
||||
`[id*="${ELEMENT_IDS.GEMINI_INPUT_BAR_ELEMENT}"]`,
|
||||
),
|
||||
)
|
||||
if (existingMarkers.length > 1) {
|
||||
debugGemini("removed duplicate markers", existingMarkers.length)
|
||||
existingMarkers.forEach((marker) => marker.remove())
|
||||
for (const marker of existingMarkers) {
|
||||
marker.remove()
|
||||
}
|
||||
} else if (existingMarkers.length === 1) {
|
||||
debugGemini("marker already exists")
|
||||
return
|
||||
|
|
@ -180,9 +184,7 @@ function addSupermemoryIconToGeminiInput() {
|
|||
})),
|
||||
})
|
||||
|
||||
const micButton = buttons.find((button) =>
|
||||
isGeminiMicButton(button),
|
||||
)
|
||||
const micButton = buttons.find((button) => isGeminiMicButton(button))
|
||||
const sendButton = buttons.find((button) => isGeminiSendButton(button))
|
||||
const anchorButton = micButton || sendButton || buttons[buttons.length - 1]
|
||||
const anchorSlot = findGeminiButtonSlot(anchorButton, composer)
|
||||
|
|
@ -259,8 +261,9 @@ function findGeminiComposerButtons(
|
|||
return allButtons.filter((button) => {
|
||||
const rect = button.getBoundingClientRect()
|
||||
const verticallyNear =
|
||||
Math.abs(rect.top + rect.height / 2 - (inputRect.top + inputRect.height / 2)) <
|
||||
120
|
||||
Math.abs(
|
||||
rect.top + rect.height / 2 - (inputRect.top + inputRect.height / 2),
|
||||
) < 120
|
||||
const horizontallyNear =
|
||||
rect.left > inputRect.left - 80 && rect.left < inputRect.right + 240
|
||||
|
||||
|
|
@ -328,11 +331,7 @@ function describeElement(element: Element | null): string | null {
|
|||
if (element.id) parts.push(`#${element.id}`)
|
||||
if (element.className && typeof element.className === "string") {
|
||||
parts.push(
|
||||
`.${element.className
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.slice(0, 4)
|
||||
.join(".")}`,
|
||||
`.${element.className.trim().split(/\s+/).slice(0, 4).join(".")}`,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -364,7 +363,7 @@ function getInputText(input: GeminiInput | null): string {
|
|||
return input.innerText || input.textContent || ""
|
||||
}
|
||||
|
||||
function appendStoredMemories(input: GeminiInput, storedMemories: string) {
|
||||
function _appendStoredMemories(input: GeminiInput, storedMemories: string) {
|
||||
if (input instanceof HTMLTextAreaElement) {
|
||||
const promptContent = input.value || ""
|
||||
input.value = `${promptContent}${storedMemories}`
|
||||
|
|
@ -510,7 +509,7 @@ function setupGeminiPromptCapture() {
|
|||
}
|
||||
|
||||
const input = getGeminiPromptInput()
|
||||
let promptContent = getInputText(input)
|
||||
const promptContent = getInputText(input)
|
||||
debugGemini("capture input state", {
|
||||
hasInput: !!input,
|
||||
promptLength: promptContent.length,
|
||||
|
|
@ -541,9 +540,7 @@ function setupGeminiPromptCapture() {
|
|||
|
||||
icons.forEach((icon) => {
|
||||
const iconElement = icon as HTMLElement
|
||||
iconElement
|
||||
.querySelector("[data-supermemory-status-badge]")
|
||||
?.remove()
|
||||
iconElement.querySelector("[data-supermemory-status-badge]")?.remove()
|
||||
delete iconElement.dataset.supermemoryStatus
|
||||
delete iconElement.dataset.memoriesData
|
||||
if (iconElement.dataset.originalHtml) {
|
||||
|
|
@ -659,9 +656,7 @@ async function setupGeminiAutoFetch() {
|
|||
|
||||
icons.forEach((icon) => {
|
||||
const iconElement = icon as HTMLElement
|
||||
iconElement
|
||||
.querySelector("[data-supermemory-status-badge]")
|
||||
?.remove()
|
||||
iconElement.querySelector("[data-supermemory-status-badge]")?.remove()
|
||||
delete iconElement.dataset.supermemoryStatus
|
||||
delete iconElement.dataset.memoriesData
|
||||
if (iconElement.dataset.originalHtml) {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,10 @@ export function showMemorySuggestion(
|
|||
return suggestionText
|
||||
}
|
||||
|
||||
export function showLoadingSuggestion(platform: string, input: SuggestionInput) {
|
||||
export function showLoadingSuggestion(
|
||||
platform: string,
|
||||
input: SuggestionInput,
|
||||
) {
|
||||
removeMemorySuggestion(platform)
|
||||
|
||||
const anchor = getSuggestionAnchor(input)
|
||||
|
|
@ -134,9 +137,12 @@ function createSuggestionContainer(
|
|||
}
|
||||
|
||||
export function removeMemorySuggestion(platform: string) {
|
||||
document
|
||||
.querySelectorAll(`[${SUGGESTION_ATTR}="${platform}"]`)
|
||||
.forEach((element) => element.remove())
|
||||
const elements = document.querySelectorAll(
|
||||
`[${SUGGESTION_ATTR}="${platform}"]`,
|
||||
)
|
||||
for (const element of elements) {
|
||||
element.remove()
|
||||
}
|
||||
}
|
||||
|
||||
export function acceptMemorySuggestion(
|
||||
|
|
@ -160,7 +166,9 @@ export function acceptMemorySuggestion(
|
|||
return true
|
||||
}
|
||||
|
||||
export function hasAcceptedSupermemoryContext(input: SuggestionInput | null): boolean {
|
||||
export function hasAcceptedSupermemoryContext(
|
||||
input: SuggestionInput | null,
|
||||
): boolean {
|
||||
if (!input) return false
|
||||
const text =
|
||||
input instanceof HTMLTextAreaElement
|
||||
|
|
@ -178,7 +186,10 @@ export function syncAcceptedSupermemoryState(input: SuggestionInput | null) {
|
|||
}
|
||||
}
|
||||
|
||||
export function clearMemorySuggestion(platform: string, input: SuggestionInput | null) {
|
||||
export function clearMemorySuggestion(
|
||||
platform: string,
|
||||
input: SuggestionInput | null,
|
||||
) {
|
||||
removeMemorySuggestion(platform)
|
||||
if (input?.dataset.supermemories) {
|
||||
delete input.dataset.supermemories
|
||||
|
|
@ -194,9 +205,7 @@ export function setMemoryMarkerStatus(
|
|||
) {
|
||||
if (!iconElement) return
|
||||
|
||||
iconElement
|
||||
.querySelector("[data-supermemory-status-badge]")
|
||||
?.remove()
|
||||
iconElement.querySelector("[data-supermemory-status-badge]")?.remove()
|
||||
|
||||
if (status === "neutral" || status === "none") {
|
||||
delete iconElement.dataset.supermemoryStatus
|
||||
|
|
@ -227,9 +236,7 @@ export function showMarkerPopover(
|
|||
memories?: string,
|
||||
resetAfter = 0,
|
||||
) {
|
||||
iconElement
|
||||
.querySelector("[data-supermemory-marker-popover]")
|
||||
?.remove()
|
||||
iconElement.querySelector("[data-supermemory-marker-popover]")?.remove()
|
||||
ensureSuggestionAnimationStyle()
|
||||
|
||||
const popover = document.createElement("div")
|
||||
|
|
|
|||
|
|
@ -77,12 +77,11 @@ export async function saveMemory(
|
|||
if (response?.success) {
|
||||
DOMUtils.showToast("success")
|
||||
return response
|
||||
} else {
|
||||
DOMUtils.showToast("error")
|
||||
return {
|
||||
success: false,
|
||||
error: response?.error || "Failed to save memory",
|
||||
}
|
||||
}
|
||||
DOMUtils.showToast("error")
|
||||
return {
|
||||
success: false,
|
||||
error: response?.error || "Failed to save memory",
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error saving memory:", error)
|
||||
|
|
|
|||
|
|
@ -442,7 +442,9 @@ function App() {
|
|||
throw new Error(response?.error || "Failed to save current page")
|
||||
} catch (error) {
|
||||
console.error("Failed to save current page:", error)
|
||||
setSaveError(error instanceof Error ? error.message : "Could not save page")
|
||||
setSaveError(
|
||||
error instanceof Error ? error.message : "Could not save page",
|
||||
)
|
||||
|
||||
try {
|
||||
const tabs = await chrome.tabs.query({
|
||||
|
|
|
|||
|
|
@ -16,11 +16,7 @@ function Welcome() {
|
|||
<main className="relative mx-auto flex min-h-screen w-full max-w-6xl flex-col px-6 py-6 sm:px-10">
|
||||
<header className="flex items-center justify-between border-b border-white/10 pb-5">
|
||||
<div className="flex items-center gap-2">
|
||||
<img
|
||||
alt=""
|
||||
className="size-8 rounded-[4px]"
|
||||
src="./icon-48.png"
|
||||
/>
|
||||
<img alt="" className="size-8 rounded-[4px]" src="./icon-48.png" />
|
||||
<img
|
||||
alt="supermemory"
|
||||
className="h-6 w-auto"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue