A Chrome Extension that allows you to preview HTML files directly from GitHub Pull Request's "Files Changed" view.
- Automatically detects HTML files in PR file changes
- Adds a "Preview" button next to each HTML file
- Opens HTML preview in a new tab
- Supports both light and dark GitHub themes
- Handles relative URLs in HTML files
- Clone or download this repository
- Open Chrome and navigate to
chrome://extensions - Enable "Developer mode" using the toggle in the top-right corner
- Click "Load unpacked"
- Select the
github-pr-html-previewfolder - The extension is now installed and active
- Navigate to any GitHub Pull Request's "Files changed" tab
- Example:
https://github.com/owner/repo/pull/123/files
- Example:
- For any HTML file in the changes, you'll see a green "Preview" button
- Click the "Preview" button to open the HTML file in a new tab
- The preview shows the rendered HTML as it would appear in a browser
- Content Script: Scans the PR files changed page for HTML files and injects "Preview" buttons
- Background Service Worker: Handles opening new tabs with the preview page
- Preview Page: Fetches the raw HTML content from
raw.githubusercontent.comand renders it in an iframe
github-pr-html-preview/
├── manifest.json # Extension configuration (Manifest V3)
├── src/
│ ├── content/
│ │ ├── content.js # GitHub page content script
│ │ └── content.css # Preview button styles
│ ├── background/
│ │ └── service-worker.js # Background service worker
│ └── preview/
│ ├── preview.html # Preview page template
│ └── preview.js # Preview loading logic
├── icons/
│ ├── icon16.png
│ ├── icon48.png
│ └── icon128.png
└── README.md
The extension requires the following permissions:
activeTab: To interact with the current GitHub tabscripting: To inject content scripts- Host permissions for:
https://github.com/*: To add preview buttons on GitHubhttps://raw.githubusercontent.com/*: To fetch raw HTML content
- Only works on public repositories or repositories you have access to
- External resources (CSS, JS, images) referenced with relative paths are rewritten to point to raw.githubusercontent.com
- Some dynamic features of the HTML may not work due to CORS restrictions
MIT License