diff --git a/src/detector.js b/src/detector.js deleted file mode 100644 index ee6be0b..0000000 --- a/src/detector.js +++ /dev/null @@ -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 diff --git a/src/main.js b/src/main.js index b43acb4..705ad6b 100644 --- a/src/main.js +++ b/src/main.js @@ -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; } diff --git a/src/project_meta.js b/src/project_meta.js new file mode 100644 index 0000000..581bf47 --- /dev/null +++ b/src/project_meta.js @@ -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