Refactor to do better metadata analysis on the current project/chat

This commit is contained in:
2025-07-13 16:22:43 -04:00
parent dfaec2ccd3
commit 28bbce8b79
3 changed files with 29 additions and 18 deletions

View File

@ -1,17 +0,0 @@
const ProjectDetector = {
isProjectChat() {
const projectLink = document.querySelector('a[href*="/project/"]');
if (!projectLink) {
console.log('Not in a project chat - no project link found');
return false;
}
// Additional check: look for the forward slash separator in the project breadcrumb
const breadcrumbWithSlash = projectLink.querySelector('span.opacity-50');
if (!breadcrumbWithSlash || !breadcrumbWithSlash.textContent.includes('/')) {
console.log('Not in a project chat - no forward slash separator found');
return false;
}
return true;
}
};// No exports needed - will be in same scope after build

View File

@ -1,7 +1,7 @@
async function main() {
console.log('Running artifact collector');
if (!ProjectDetector.isProjectChat()) {
if (!ProjectMeta.isProjectChat()) {
console.log('Not in a project chat, exiting');
return;
}

28
src/project_meta.js Normal file
View File

@ -0,0 +1,28 @@
const ProjectMeta = {
getProjectName() {
const projectLink = document.querySelector('a[href*="/project/"]');
if (!projectLink) {
return null;
}
// Get the full text and strip trailing spaces and forward slashes
const projectName = projectLink.innerText.replace(/\s*\/.*$/, '').trim();
return projectName || null;
},
getChatName() {
const chatNameDiv = document.querySelector('button[data-testid="chat-menu-trigger"] div.truncate');
if (!chatNameDiv) {
return null;
}
return chatNameDiv.textContent.trim() || null;
},
isProjectChat() {
return Boolean(this.getProjectName()) && Boolean(this.getChatName());
}
};
// No exports needed - will be in same scope after build;// No exports needed - will be in same scope after build