Initial commit

This commit is contained in:
2026-07-29 22:26:19 -04:00
commit 8818c79d4d
11 changed files with 2592 additions and 0 deletions
+86
View File
@@ -0,0 +1,86 @@
(() => {
const messages = [];
const selectors = [
".assistant-msg-container, .user-msg-container",
'[class*="msg-container"]',
".message-container",
"article",
'[data-testid="message"]',
".chat-message",
];
let containers = [];
for (const sel of selectors) {
const found = document.querySelectorAll(sel);
if (found.length > 0) {
containers = Array.from(found);
break;
}
}
if (containers.length === 0) {
console.log("No message containers found");
return [];
}
containers.forEach((container) => {
const isUser =
container.classList.contains("user-msg-container") ||
container.classList.contains("user") ||
container.getAttribute("data-role") === "user";
let content = "";
const images = [];
const textSelectors = [
".whitespace-pre-line",
".progressive-markdown-content",
'[class*="content"]',
"p",
"div",
'[class*="text"]',
];
for (const tSel of textSelectors) {
const textEl = container.querySelector(tSel);
if (textEl && textEl.textContent.trim().length > 10) {
content = textEl.textContent.trim();
break;
}
}
const imgEls = container.querySelectorAll(
'.inline-image-card img, img[alt="Generated image"]',
);
imgEls.forEach((img) => {
try {
const canvas = document.createElement("canvas");
canvas.width = img.naturalWidth;
canvas.height = img.naturalHeight;
if (canvas.width > 0 && canvas.height > 0) {
canvas.getContext("2d").drawImage(img, 0, 0);
images.push({
src: canvas.toDataURL("image/png"),
alt: img.alt || "Generated image",
});
}
} catch (_e) {}
});
if (content || images.length > 0) {
messages.push({
role: isUser ? "user" : "assistant",
content: content,
images: images,
});
}
});
window.scannedMessages = messages;
console.log(
`Extracted ${messages.length} messages. Stored in window.scannedMessages`,
);
const blob = new Blob([JSON.stringify(messages, null, 2)], {
type: "application/json",
});
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `lumo-messages-${new Date().toISOString().slice(0, 19).replace(/[:T]/g, "-")}.json`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
return messages;
})();