A browser extension that lets you summarize any webpage and ask questions using AI.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add PDF file detection with user-friendly error message

- Add isPdfUrl() to detect PDF files by URL pattern
- Add showPdfError() to display helpful error UI when PDFs are detected
- Add CSS styles for PDF error state (.pdf-error, .pdf-error-icon, etc.)
- Skip summarization for PDFs and show guidance to use external tools

+66
+33
popup/popup.css
··· 488 488 line-height: 1.5; 489 489 } 490 490 491 + /* ── PDF Error ── */ 492 + .pdf-error { 493 + display: flex; 494 + flex-direction: column; 495 + align-items: center; 496 + justify-content: center; 497 + height: 100%; 498 + text-align: center; 499 + padding: 40px 20px; 500 + gap: 12px; 501 + } 502 + 503 + .pdf-error-icon { 504 + font-size: 48px; 505 + font-weight: 300; 506 + color: var(--text-muted); 507 + margin-bottom: 8px; 508 + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; 509 + } 510 + 511 + .pdf-error-title { 512 + font-size: 16px; 513 + font-weight: 600; 514 + color: var(--text); 515 + } 516 + 517 + .pdf-error-message { 518 + font-size: 13px; 519 + color: var(--text-muted); 520 + line-height: 1.6; 521 + max-width: 280px; 522 + } 523 + 491 524 /* ── Toast ── */ 492 525 .toast { 493 526 position: fixed;
+33
popup/popup.js
··· 313 313 currentTabId = tab?.id; 314 314 currentTabUrl = tab?.url; 315 315 316 + // Check if this is a PDF file 317 + if (isPdfUrl(currentTabUrl)) { 318 + showPdfError(); 319 + return; 320 + } 321 + 316 322 // Check for cached summary for this tab 317 323 const cached = await chrome.storage.session.get([ 318 324 QUICK_SUMMARY_CACHE_PREFIX + currentTabId, ··· 1262 1268 div.textContent = text; 1263 1269 return div.innerHTML; 1264 1270 } 1271 + 1272 + function isPdfUrl(url) { 1273 + if (!url) return false; 1274 + // Check for .pdf extension or PDF in the URL path 1275 + const urlObj = new URL(url); 1276 + const pathname = urlObj.pathname.toLowerCase(); 1277 + return pathname.endsWith('.pdf') || pathname.includes('.pdf?'); 1278 + } 1279 + 1280 + function showPdfError() { 1281 + // Hide initial state and show error 1282 + initialState.classList.add("hidden"); 1283 + resultContainer.classList.remove("hidden"); 1284 + footer.classList.add("hidden"); 1285 + chatContainer.classList.add("hidden"); 1286 + 1287 + resultContainer.innerHTML = ` 1288 + <div class="pdf-error"> 1289 + <div class="pdf-error-icon">:(</div> 1290 + <div class="pdf-error-title">PDF files aren't supported</div> 1291 + <div class="pdf-error-message"> 1292 + This extension can't extract text from PDFs. 1293 + To summarize this document, download the file and upload it to a tool like ChatGPT. 1294 + </div> 1295 + </div> 1296 + `; 1297 + }