Refactor activity image error handling and clean up debug_bestbuy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-01 22:27:06 -04:00
parent d33639fdc7
commit c6bc09c0d3
3 changed files with 320 additions and 871 deletions
+15 -2
View File
@@ -281,7 +281,7 @@ async function loadActivityFeed() {
return `
<div class="activity-item">
${hasProductImage
? `<img src="${event.image_url}" class="activity-thumb" alt="" onerror="this.outerHTML=\`${storeLogoHtml.replace(/`/g, '\\`').replace(/\n/g, '')}\`">`
? `<img src="${event.image_url}" class="activity-thumb" alt="" onerror="handleActivityImageError(this, '${event.site}')">`
: storeLogoHtml
}
<div class="activity-details">
@@ -297,6 +297,19 @@ async function loadActivityFeed() {
}).join('');
}
function handleActivityImageError(img, site) {
const storeInfo = STORE_INFO[site] || { name: site, color: '#333', bgColor: '#666', logo: '', fallback: '?' };
const div = document.createElement('div');
div.className = 'activity-store-icon';
div.style.background = storeInfo.bgColor;
div.innerHTML = `
<img src="${storeInfo.logo}" alt="${storeInfo.name}" class="activity-store-logo"
onerror="this.style.display='none'; this.nextElementSibling.style.display='block';">
<span class="activity-store-fallback" style="display:none; color:${storeInfo.color};">${storeInfo.fallback}</span>
`;
img.replaceWith(div);
}
// Navigate to products filtered by event type
function goToFilteredProducts(eventType, period) {
currentEventFilter = { type: eventType, period: period };
@@ -718,7 +731,7 @@ function cleanProductName(name) {
.replace(/\{[^}]*\}/g, '') // Remove any remaining {css} blocks
.replace(/\d+\s*Reviews?$/i, '') // Remove trailing "X Reviews"
// Fix Pokémon - multiple encoding patterns
.replace(/Pok[éÃ\u00c3\u00a9]+mon/gi, 'Pokémon')
.replace(/Pok[éÃ\u00c3\u00a9\ufffd]+mon/gi, 'Pokémon')
.replace(/Pokémon/gi, 'Pokémon')
.replace(/Pok&eacute;mon/gi, 'Pokémon')
.replace(/Pokテゥmon/gi, 'Pokémon')