PDF Interceptor is a lightweight Chrome extension that spots PDF responses as you browse. It flashes a floating Download PDF button inside the page for manual downloads, and—when "auto mode" is enabled—grabs the file automatically as soon as the network request completes, then closes the tab.
- Detects PDF requests on any site using a Manifest V3 background service worker
- Manual download button injected via
content.jswith inline styling that avoids host-page conflicts - Auto mode toggle exposed in the extension popup (
popup.html/popup.js) - Auto downloads tracked in the background so authenticated PDFs continue to work, followed by automatic tab closure
| File | Purpose |
|---|---|
manifest.json |
Declares metadata, permissions (webRequest, tabs, downloads, storage), action popup, and content script wiring |
background.js |
Service-worker context that tracks last PDF per tab, relays messages, and executes auto downloads |
content.js |
Injected script that renders the floating button and forwards clicks back to the background worker |
popup.html / popup.js |
Popup UI that lets users toggle auto mode and persists the state with chrome.storage.local |
AGENTS.md |
Contributor guidelines and coding conventions |
- Clone the repo locally.
- Open
chrome://extensions, enable Developer mode, and click Load unpacked. - Select the repository root. The extension icon should appear in the toolbar.
- Click the icon to open the popup and toggle Auto Mode on or off. The state persists via
chrome.storage.
- Browse to any link that ends in
.pdf(or servesapplication/pdf). - When the button appears, click Download PDF to trigger a background download.
- Enable auto mode in the popup.
- Open a PDF link in a new tab; the background worker downloads it instantly.
- Once Chrome reports the download as complete, the tab is closed automatically. Interrupted downloads remove the tab from the queue without closing it.
zip -r dist/pdf-interceptor.zip manifest.json background.js content.js popup.html popup.jsUpload the archive to the Chrome Web Store dashboard. Remember to increment the version field in manifest.json first.
- Manual PDF download appears and works on both public and authenticated pages
- Auto mode downloads and closes the correct tab without affecting others
- Button hides on non-PDF pages and reappears when revisiting a PDF tab (via
GET_LAST_PDF) - Multiple PDF tabs operate independently (check
lastPdfByTabseparation)
See AGENTS.md for style conventions, commit expectations, and security tips. PRs should list the manual scenarios executed and highlight any permission changes.