Files
crawl4ai/docs/md_v2/apps/crawl4ai-assistant/content/content.js
UncleCode 0ac12da9f3 feat: Major Chrome Extension overhaul with Click2Crawl, instant Schema extraction, and modular architecture
 New Features:
- Click2Crawl: Visual element selection with markdown conversion
  - Ctrl/Cmd+Click to select multiple elements
  - Visual text mode for WYSIWYG extraction
  - Real-time markdown preview with syntax highlighting
  - Export to .md file or clipboard

- Schema Builder Enhancement: Instant data extraction without LLMs
  - Test schemas directly in browser
  - See JSON results immediately
  - Export data or Python code
  - Cloud deployment ready (coming soon)

- Modular Architecture:
  - Separated into schemaBuilder.js, scriptBuilder.js, click2CrawlBuilder.js
  - Added contentAnalyzer.js and markdownConverter.js modules
  - Shared utilities and CSS reset system
  - Integrated marked.js for markdown rendering

🎨 UI/UX Improvements:
- Added edgy cloud announcement banner with seamless shimmer animation
- Direct, technical copy: "You don't need Puppeteer. You need Crawl4AI Cloud."
- Enhanced feature cards with emojis
- Fixed CSS conflicts with targeted reset approach
- Improved badge hover effects (red on hover)
- Added wrap toggle for code preview

📚 Documentation Updates:
- Split extraction diagrams into LLM and no-LLM versions
- Updated llms-full.txt with latest content
- Added versioned LLM context (v0.1.1)

🔧 Technical Enhancements:
- Refactored 3464 lines of monolithic content.js into modules
- Added proper event handling and cleanup
- Improved z-index management
- Better scroll position tracking for badges
- Enhanced error handling throughout

This release transforms the Chrome Extension from a simple tool into a powerful
visual data extraction suite, making web scraping accessible to everyone.
2025-06-09 23:18:27 +08:00

78 lines
2.3 KiB
JavaScript

// Main content script for Crawl4AI Assistant
// Coordinates between SchemaBuilder and ScriptBuilder
let activeBuilder = null;
// Listen for messages from popup
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === 'startCapture') {
if (activeBuilder) {
console.log('Stopping existing capture session');
activeBuilder.stop();
activeBuilder = null;
}
if (request.mode === 'schema') {
console.log('Starting Schema Builder');
activeBuilder = new SchemaBuilder();
activeBuilder.start();
} else if (request.mode === 'script') {
console.log('Starting Script Builder');
activeBuilder = new ScriptBuilder();
activeBuilder.start();
}
sendResponse({ success: true });
} else if (request.action === 'stopCapture') {
if (activeBuilder) {
activeBuilder.stop();
activeBuilder = null;
}
sendResponse({ success: true });
} else if (request.action === 'startSchemaCapture') {
if (activeBuilder) {
activeBuilder.deactivate?.();
activeBuilder = null;
}
console.log('Starting Schema Builder');
activeBuilder = new SchemaBuilder();
activeBuilder.start();
sendResponse({ success: true });
} else if (request.action === 'startScriptCapture') {
if (activeBuilder) {
activeBuilder.deactivate?.();
activeBuilder = null;
}
console.log('Starting Script Builder');
activeBuilder = new ScriptBuilder();
activeBuilder.start();
sendResponse({ success: true });
} else if (request.action === 'startClick2Crawl') {
if (activeBuilder) {
activeBuilder.deactivate?.();
activeBuilder = null;
}
console.log('Starting Click2Crawl');
activeBuilder = new Click2CrawlBuilder();
sendResponse({ success: true });
} else if (request.action === 'generateCode') {
if (activeBuilder && activeBuilder.generateCode) {
activeBuilder.generateCode();
}
sendResponse({ success: true });
}
});
// Cleanup on page unload
window.addEventListener('beforeunload', () => {
if (activeBuilder) {
if (activeBuilder.deactivate) {
activeBuilder.deactivate();
} else if (activeBuilder.stop) {
activeBuilder.stop();
}
activeBuilder = null;
}
});
console.log('Crawl4AI Assistant content script loaded');