This commit introduces significant enhancements to the Crawl4AI ecosystem: Chrome Extension - Script Builder (Alpha): - Add recording functionality to capture user interactions (clicks, typing, scrolling) - Implement smart event grouping for cleaner script generation - Support export to both JavaScript and C4A script formats - Add timeline view for visualizing and editing recorded actions - Include wait commands (time-based and element-based) - Add saved flows functionality for reusing automation scripts - Update UI with consistent dark terminal theme (Dank Mono font, green/pink accents) - Release new extension versions: v1.1.0, v1.2.0, v1.2.1 LLM Context Builder Improvements: - Reorganize context files from llmtxt/ to llm.txt/ with better structure - Separate diagram templates from text content (diagrams/ and txt/ subdirectories) - Add comprehensive context files for all major Crawl4AI components - Improve file naming convention for better discoverability Documentation Updates: - Update apps index page to match main documentation theme - Standardize color scheme: "Available" tags use primary color (#50ffff) - Change "Coming Soon" tags to dark gray for better visual hierarchy - Add interactive two-column layout for extension landing page - Include code examples for both Schema Builder and Script Builder features Technical Improvements: - Enhance event capture mechanism with better element selection - Add support for contenteditable elements and complex form interactions - Implement proper scroll event handling for both window and element scrolling - Add meta key support for keyboard shortcuts - Improve selector generation for more reliable element targeting The Script Builder is released as Alpha, acknowledging potential bugs while providing early access to this powerful automation recording feature.
129 lines
3.7 KiB
JavaScript
129 lines
3.7 KiB
JavaScript
// Popup script for Crawl4AI Assistant
|
|
let activeMode = null;
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
// Fetch GitHub stars
|
|
fetchGitHubStars();
|
|
|
|
// Check current state
|
|
chrome.storage.local.get(['captureMode', 'captureStats'], (data) => {
|
|
if (data.captureMode) {
|
|
activeMode = data.captureMode;
|
|
showActiveSession(data.captureStats || {});
|
|
}
|
|
});
|
|
|
|
// Mode buttons
|
|
document.getElementById('schema-mode').addEventListener('click', () => {
|
|
startSchemaCapture();
|
|
});
|
|
|
|
document.getElementById('script-mode').addEventListener('click', () => {
|
|
startScriptCapture();
|
|
});
|
|
|
|
// Session actions
|
|
document.getElementById('generate-code').addEventListener('click', () => {
|
|
generateCode();
|
|
});
|
|
|
|
document.getElementById('stop-capture').addEventListener('click', () => {
|
|
stopCapture();
|
|
});
|
|
});
|
|
|
|
async function fetchGitHubStars() {
|
|
try {
|
|
const response = await fetch('https://api.github.com/repos/unclecode/crawl4ai');
|
|
const data = await response.json();
|
|
const stars = data.stargazers_count;
|
|
|
|
// Format the number (e.g., 1.2k)
|
|
let formattedStars;
|
|
if (stars >= 1000) {
|
|
formattedStars = (stars / 1000).toFixed(1) + 'k';
|
|
} else {
|
|
formattedStars = stars.toString();
|
|
}
|
|
|
|
document.getElementById('stars-count').textContent = `⭐ ${formattedStars}`;
|
|
} catch (error) {
|
|
console.error('Failed to fetch GitHub stars:', error);
|
|
document.getElementById('stars-count').textContent = '⭐ 2k+';
|
|
}
|
|
}
|
|
|
|
function startSchemaCapture() {
|
|
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
|
chrome.tabs.sendMessage(tabs[0].id, {
|
|
action: 'startSchemaCapture'
|
|
}, (response) => {
|
|
if (response && response.success) {
|
|
// Close the popup to let user interact with the page
|
|
window.close();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
function startScriptCapture() {
|
|
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
|
chrome.tabs.sendMessage(tabs[0].id, {
|
|
action: 'startScriptCapture'
|
|
}, (response) => {
|
|
if (response && response.success) {
|
|
// Close the popup to let user interact with the page
|
|
window.close();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
function showActiveSession(stats) {
|
|
document.querySelector('.mode-selector').style.display = 'none';
|
|
document.getElementById('active-session').classList.remove('hidden');
|
|
|
|
updateSessionStats(stats);
|
|
}
|
|
|
|
function updateSessionStats(stats) {
|
|
document.getElementById('container-status').textContent =
|
|
stats.container ? 'Selected ✓' : 'Not selected';
|
|
document.getElementById('fields-count').textContent = stats.fields || 0;
|
|
|
|
// Enable generate button if we have container and fields
|
|
document.getElementById('generate-code').disabled =
|
|
!stats.container || stats.fields === 0;
|
|
}
|
|
|
|
function generateCode() {
|
|
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
|
chrome.tabs.sendMessage(tabs[0].id, {
|
|
action: 'generateCode'
|
|
});
|
|
});
|
|
}
|
|
|
|
function stopCapture() {
|
|
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
|
chrome.tabs.sendMessage(tabs[0].id, {
|
|
action: 'stopCapture'
|
|
}, () => {
|
|
// Reset UI
|
|
document.querySelector('.mode-selector').style.display = 'flex';
|
|
document.getElementById('active-session').classList.add('hidden');
|
|
activeMode = null;
|
|
|
|
// Clear storage
|
|
chrome.storage.local.remove(['captureMode', 'captureStats']);
|
|
});
|
|
});
|
|
}
|
|
|
|
// Listen for stats updates from content script
|
|
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|
if (message.action === 'updateStats') {
|
|
updateSessionStats(message.stats);
|
|
chrome.storage.local.set({ captureStats: message.stats });
|
|
}
|
|
}); |