diff --git a/README.md b/README.md index 8191122..8f4f4a1 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,5 @@ There's a `<-` arrow on the top right you can click to open the sidebar if it's If you've followed the other steps, you should see some activity in the chat page's console, then see a zip file downloaded with all the artifacts correctly mapped inside. -## Changes under consideration -1. Optionally scrape project-level artifacts instead of chat-level artifacts -2. Fix the scraper to work with single-artifact chats that don't have a selector button. Not sure how we'll get the artifact name here. +## Known bugs +1. Fix the scraper to work with single-artifact chats that don't have a selector button. Not sure how we'll get the artifact name here. diff --git a/src/main.js b/src/main.js index 71811db..72361c3 100644 --- a/src/main.js +++ b/src/main.js @@ -1,8 +1,17 @@ async function main() { console.log('Running artifact collector'); + const currentUrl = window.location.href; + const isProjectPage = currentUrl.includes('/project/'); + 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 chat, exiting'); + console.log('Not in a project context, exiting'); return; } diff --git a/src/scraper.js b/src/scraper.js index 8a8b570..f209767 100644 --- a/src/scraper.js +++ b/src/scraper.js @@ -215,7 +215,7 @@ const ChatArtifactScraper = { try { const content = await this.getArtifact(filename, isSelected); - if (filename === 'files.txt') { + if (filename.toLowerCase().indexOf('files.txt') !== -1) { fileMap = content; console.log(`✓ Found files.txt - storing in fileMap`); } else { @@ -320,7 +320,6 @@ const ProjectArtifactScraper = { const artifactList = this.getArtifactListItems(); if (Object.keys(artifactList).length === 0) { - console.log('Nada'); return { artifacts: artifactCollection, fileMap: fileMap }; } @@ -330,7 +329,7 @@ const ProjectArtifactScraper = { try { const content = await this.getArtifact(filename, isSelected); - if (filename === 'files.txt') { + if (filename.toLowerCase().indexOf('files.txt') !== -1) { fileMap = content; console.log(`✓ Found files.txt - storing in fileMap`); } else { @@ -351,7 +350,6 @@ const ProjectArtifactScraper = { const ArtifactScraper = { async collectArtifacts() { - console.log('Collecting') if (ProjectMeta.isProjectChat()) { console.log('Detected project chat - using ChatArtifactScraper'); return await ChatArtifactScraper.collectArtifacts();