Refactor to do better metadata analysis on the current project/chat
This commit is contained in:
@ -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
|
||||
@ -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
28
src/project_meta.js
Normal 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
|
||||
Reference in New Issue
Block a user