Remove requirement for chats to be in a project
This commit is contained in:
13
src/main.js
13
src/main.js
@ -1,17 +1,8 @@
|
|||||||
async function main() {
|
async function main() {
|
||||||
console.log('Running artifact collector');
|
console.log('Running artifact collector');
|
||||||
|
|
||||||
const currentUrl = window.location.href;
|
if (!ProjectMeta.isScrapable()) {
|
||||||
const isProjectPage = currentUrl.includes('/project/');
|
console.log('Not in a scrapable context, exiting');
|
||||||
const isChatPage = currentUrl.includes('/chat/');
|
|
||||||
|
|
||||||
if (!isProjectPage && !isChatPage) {
|
|
||||||
console.log('Not on a project or chat page, exiting');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ProjectMeta.isInProject()) {
|
|
||||||
console.log('Not in a project context, exiting');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,10 +13,10 @@ const ProjectMeta = {
|
|||||||
// Fallback: try to get from H1 (project pages)
|
// Fallback: try to get from H1 (project pages)
|
||||||
const projectH1 = document.querySelector('h1.font-ui-serif');
|
const projectH1 = document.querySelector('h1.font-ui-serif');
|
||||||
if (projectH1) {
|
if (projectH1) {
|
||||||
return projectH1.textContent.trim() || null;
|
return projectH1.textContent.trim() || 'Claude Project';
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return 'Claude Project';
|
||||||
},
|
},
|
||||||
|
|
||||||
getChatName() {
|
getChatName() {
|
||||||
@ -28,8 +28,8 @@ const ProjectMeta = {
|
|||||||
return chatNameDiv.textContent.trim() || null;
|
return chatNameDiv.textContent.trim() || null;
|
||||||
},
|
},
|
||||||
|
|
||||||
isProjectChat() {
|
isChat() {
|
||||||
return Boolean(this.getProjectName()) && Boolean(this.getChatName());
|
return Boolean(this.getChatName());
|
||||||
},
|
},
|
||||||
|
|
||||||
isProjectPage() {
|
isProjectPage() {
|
||||||
@ -40,8 +40,8 @@ const ProjectMeta = {
|
|||||||
return Boolean(this.getProjectName()) && hasProjectKnowledge;
|
return Boolean(this.getProjectName()) && hasProjectKnowledge;
|
||||||
},
|
},
|
||||||
|
|
||||||
isInProject() {
|
isScrapable() {
|
||||||
return this.isProjectChat() || this.isProjectPage();
|
return this.isChat() || this.isProjectPage();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -350,14 +350,14 @@ const ProjectArtifactScraper = {
|
|||||||
|
|
||||||
const ArtifactScraper = {
|
const ArtifactScraper = {
|
||||||
async collectArtifacts() {
|
async collectArtifacts() {
|
||||||
if (ProjectMeta.isProjectChat()) {
|
if (ProjectMeta.isChat()) {
|
||||||
console.log('Detected project chat - using ChatArtifactScraper');
|
console.log('Detected chat - using ChatArtifactScraper');
|
||||||
return await ChatArtifactScraper.collectArtifacts();
|
return await ChatArtifactScraper.collectArtifacts();
|
||||||
} else if (ProjectMeta.isProjectPage()) {
|
} else if (ProjectMeta.isProjectPage()) {
|
||||||
console.log('Detected project page - using ProjectArtifactScraper');
|
console.log('Detected project page - using ProjectArtifactScraper');
|
||||||
return await ProjectArtifactScraper.collectArtifacts();
|
return await ProjectArtifactScraper.collectArtifacts();
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Unknown page type - not a project chat or project page');
|
throw new Error('Unknown page type - not a chat or project page');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user