Fix active element selector, isolate final handler
This commit is contained in:
47
content.js
47
content.js
@ -101,8 +101,10 @@
|
|||||||
const filenameDiv = item.querySelector('div.line-clamp-2');
|
const filenameDiv = item.querySelector('div.line-clamp-2');
|
||||||
if (filenameDiv) {
|
if (filenameDiv) {
|
||||||
const filename = filenameDiv.textContent.trim();
|
const filename = filenameDiv.textContent.trim();
|
||||||
const isSelected = item.classList.contains('border-accent-secondary-100') ||
|
// Check for aria-selected attribute or other indicators of selection
|
||||||
item.getAttribute('class').includes('border-accent-secondary-100');
|
const isSelected = item.getAttribute('aria-selected') === 'true' ||
|
||||||
|
item.classList.contains('bg-accent-secondary-100') ||
|
||||||
|
item.classList.contains('border-accent-secondary-100');
|
||||||
|
|
||||||
artifactHash[filename] = isSelected;
|
artifactHash[filename] = isSelected;
|
||||||
console.log(`Found artifact: ${filename} (${isSelected ? 'selected' : 'unselected'})`);
|
console.log(`Found artifact: ${filename} (${isSelected ? 'selected' : 'unselected'})`);
|
||||||
@ -155,9 +157,10 @@
|
|||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
// If not currently selected, we need to select it
|
// If not currently selected, we need to select it
|
||||||
if (!isCurrentlySelected) {
|
if (!isCurrentlySelected) {
|
||||||
// Open menu if not already open
|
// Check if menu is already open
|
||||||
const menuOpen = document.querySelector('li[role="none"] div[role="menuitem"]');
|
const menuOpen = document.querySelector('li[role="none"] div[role="menuitem"]');
|
||||||
if (!menuOpen) {
|
if (!menuOpen) {
|
||||||
|
// Menu is not open, so open it
|
||||||
try {
|
try {
|
||||||
await this.openArtifactList();
|
await this.openArtifactList();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -193,8 +196,9 @@
|
|||||||
async collectArtifacts() {
|
async collectArtifacts() {
|
||||||
console.log('Starting artifact collection...');
|
console.log('Starting artifact collection...');
|
||||||
|
|
||||||
// Initialize empty collection
|
// Initialize empty collection and fileMap
|
||||||
const artifactCollection = {};
|
const artifactCollection = {};
|
||||||
|
let fileMap = null;
|
||||||
|
|
||||||
// Open artifact list
|
// Open artifact list
|
||||||
await this.openArtifactList();
|
await this.openArtifactList();
|
||||||
@ -204,7 +208,7 @@
|
|||||||
|
|
||||||
if (Object.keys(artifactList).length === 0) {
|
if (Object.keys(artifactList).length === 0) {
|
||||||
console.log('No artifacts found in list');
|
console.log('No artifacts found in list');
|
||||||
return;
|
return { artifacts: artifactCollection, fileMap: fileMap };
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Found ${Object.keys(artifactList).length} artifacts to collect`);
|
console.log(`Found ${Object.keys(artifactList).length} artifacts to collect`);
|
||||||
@ -215,8 +219,15 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const content = await this.getArtifact(filename, isSelected);
|
const content = await this.getArtifact(filename, isSelected);
|
||||||
artifactCollection[filename] = content;
|
|
||||||
console.log(`✓ Collected: ${filename}`);
|
// Check if this is files.txt
|
||||||
|
if (filename === 'files.txt') {
|
||||||
|
fileMap = content;
|
||||||
|
console.log(`✓ Found files.txt - storing in fileMap`);
|
||||||
|
} else {
|
||||||
|
artifactCollection[filename] = content;
|
||||||
|
console.log(`✓ Collected: ${filename}`);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`✗ Failed to collect: ${filename} - ${error.message}`);
|
console.log(`✗ Failed to collect: ${filename} - ${error.message}`);
|
||||||
}
|
}
|
||||||
@ -225,15 +236,22 @@
|
|||||||
await new Promise(resolve => setTimeout(resolve, 500));
|
await new Promise(resolve => setTimeout(resolve, 500));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log final collection
|
return { artifacts: artifactCollection, fileMap: fileMap };
|
||||||
console.log('=== ARTIFACT COLLECTION COMPLETE ===');
|
|
||||||
console.log(`Collected ${Object.keys(artifactCollection).length} artifacts:`);
|
|
||||||
console.log(artifactCollection);
|
|
||||||
|
|
||||||
return artifactCollection;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Export function to handle logging of collected artifacts
|
||||||
|
function exportArtifacts(artifactCollection, fileMap) {
|
||||||
|
console.log('=== ARTIFACT COLLECTION COMPLETE ===');
|
||||||
|
console.log(`Collected ${Object.keys(artifactCollection).length} artifacts:`);
|
||||||
|
console.log(artifactCollection);
|
||||||
|
|
||||||
|
if (fileMap) {
|
||||||
|
console.log('=== FILE MAP ===');
|
||||||
|
console.log(fileMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Main function
|
// Main function
|
||||||
async function main() {
|
async function main() {
|
||||||
console.log('Running artifact collector');
|
console.log('Running artifact collector');
|
||||||
@ -242,7 +260,8 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ArtifactScraper.collectArtifacts();
|
const result = await ArtifactScraper.collectArtifacts();
|
||||||
|
exportArtifacts(result.artifacts, result.fileMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the main function
|
// Run the main function
|
||||||
|
|||||||
Reference in New Issue
Block a user