feat: add live DOM scraper, activity detail-fetch for video streams, and raw activity archiving

This commit is contained in:
2026-08-23 11:45:43 -07:00
parent 630936fac3
commit 30e7189601
2 changed files with 98 additions and 3 deletions
+57 -1
View File
@@ -40,8 +40,17 @@
return true;
}
if (message.action === 'SCRAPE_DOM_FEED') {
try {
const domActivities = scrapeDomFeedCards();
sendResponse({ success: true, activities: domActivities, htmlSample: document.body.innerHTML.substring(0, 5000) });
} catch (err) {
sendResponse({ success: false, error: err.message });
}
return true;
}
if (message.action === 'FETCH_WITH_CREDENTIALS') {
// Execute fetch inside page context with credentials
fetch(message.url, {
method: message.method || 'GET',
headers: {
@@ -65,6 +74,53 @@
}
});
// DOM Scraper for Brightwheel Web Feed
function scrapeDomFeedCards() {
const results = [];
// Broad selector covering common Brightwheel feed cards
const cardSelectors = [
'[data-testid*="activity"]',
'[data-testid*="feed"]',
'.activity-item',
'.feed-item',
'.timeline-item',
'article',
'[class*="ActivityCard"]',
'[class*="feed-card"]',
'[class*="FeedItem"]',
'[class*="TimelineItem"]'
];
let cards = document.querySelectorAll(cardSelectors.join(','));
if (!cards || cards.length === 0) {
// Fallback: look for cards by common structure
cards = document.querySelectorAll('div[class*="card"], div[class*="Card"]');
}
cards.forEach((card, index) => {
const text = card.innerText || '';
if (!text.trim()) return;
const cardId = card.getAttribute('data-id') || card.getAttribute('data-activity-id') || card.id || `dom_${index}`;
const img = card.querySelector('img[src*="cdn"], img[src*="brightwheel"], img[src*="cloudfront"], img[src*="s3"]');
const video = card.querySelector('video, source, a[href*=".mp4"], a[href*="video"]');
const videoUrl = video?.src || video?.getAttribute('src') || video?.getAttribute('href') || null;
const imageUrl = img?.src || null;
results.push({
dom_id: cardId,
raw_text: text,
image_url: imageUrl,
video_url: videoUrl,
class_name: card.className,
html_snippet: card.outerHTML.substring(0, 800)
});
});
return results;
}
// Inject a discreet floating button on Brightwheel page
function injectExporterButton() {
if (document.getElementById('bw-exporter-floating-btn')) return;