How rapabru/github-download-button works
This Chromium extension adds repository-aware download controls to GitHub pages. Its main workflow detects a repository, resolves the current or chosen ref, presents download choices, and delegates downloads to the service worker; the “files only” option additionally repackages an archive in an offscreen document. The README documents branch and release listings, private-repository fallbacks, and SPA resynchronization. Some source excerpts are partial, so uncertain internal wiring is omitted.
Main entry points: content.js Detection and UI · background.js Download service worker · offscreen.js Archive fetch and filtering · styles.css Button and popover styles
Components 15
GitHub page experience
- Detection and UI
content.js - Button and popover styles
styles.css
Repository discovery
- Repo and ref resolution
content.js - Branch listing
content.js - Release listing
content.js
Download handling
- Download service worker
background.js
ZIP repackaging
- Offscreen document
offscreen.html - Archive fetch and filtering
offscreen.js - ZIP reader and writer
zip.js
Other components
- GitHub visitor
- Repository page
- GitHub refs endpoint
- GitHub REST API
- Repository archive
- Browser downloads
Connections 23
- GitHub visitor → Detection and UI: uses controls
- Repository page → Detection and UI: provides page
- Detection and UI → Button and popover styles: uses styles
- Detection and UI → Repo and ref resolution: detects and resolves
- Detection and UI → Branch listing: requests branches
- Detection and UI → Release listing: requests releases
- Branch listing → GitHub refs endpoint: fetches refs
- Release listing → GitHub refs endpoint: falls back to tags
- Branch listing → Detection and UI: falls back to API
- Release listing → Detection and UI: falls back to API
- Detection and UI → Download service worker: sends messages
- Download service worker → GitHub REST API: fetches API
- Detection and UI → Download service worker: requests download
- Download service worker → Repository archive: probes URL
- Download service worker → Browser downloads: starts download
- Detection and UI → Download service worker: requests repack
- Download service worker → Offscreen document: creates document
- Download service worker → Archive fetch and filtering: dispatches repack
- Archive fetch and filtering → Repository archive: fetches ZIP
- Archive fetch and filtering → ZIP reader and writer: reads and builds
- Archive fetch and filtering → Download service worker: returns blob URL
- Download service worker → Browser downloads: downloads repacked ZIP
- Download service worker → Detection and UI: reports progress