A lightweight Chrome extension that displays your current viewport size and corresponding Tailwind CSS breakpoint in real-time.
Tailgunner helps web developers by providing an unobtrusive, real-time display of:
- Current viewport dimensions (width Γ height)
- Active Tailwind CSS breakpoint
The extension creates a semi-transparent panel in the bottom-right corner of your browser that updates automatically as you resize your window, making it easier to develop responsive designs with Tailwind CSS.
- Download or clone this repository
- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" using the toggle in the top-right corner
- Click "Load unpacked" and select the Tailgunner directory
- The extension should now appear in your toolbar
- Navigate to any webpage.
- Click the Tailgunner icon in your Chrome toolbar.
- A panel will appear in the bottom-right corner of your browser.
- The panel shows current viewport dimensions and the active Tailwind CSS breakpoint.
- Resize your browser window to see the values update in real-time.
- Click the extension icon again to hide the panel.
- Real-time Viewport Size: Displays the current width and height in pixels
- Tailwind Breakpoint Detection: Shows which Tailwind breakpoint is active
- Standard Breakpoints: Supports all standard Tailwind breakpoints (sm, md, lg, xl, 2xl)
- Unobtrusive Design: Semi-transparent panel stays out of your way
- Toggle Visibility: Easily show/hide with a single click
- Responsive Updates: Updates instantly as you resize your browser
The extension uses Manifest V3 and requires minimal permissions to function:
| Permission | Purpose | Justification |
|---|---|---|
activeTab |
Allows the extension to interact with the currently active tab | Required to inject the viewport panel into the current page. Limited to the active tab only for security and privacy. Does not access browsing history or other tabs. |
host_permissions: <all_urls> |
Allows content scripts to run on all websites | Required to show the viewport panel on any website. Does not collect any data from these sites. |
Manifest settings:
{
"manifest_version": 3,
"name": "Tailgunner",
"description": "Displays viewport size and Tailwind CSS breakpoint",
"version": "1.0.1",
"permissions": [
"activeTab"
],
"host_permissions": [
"<all_urls>"
],
"background": {
"service_worker": "background.js"
},
"action": {
"default_title": "Toggle Tailgunner Panel"
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"content.js"
],
"run_at": "document_idle"
}
]
}- manifest_version: 3 - Uses the latest, most secure manifest version as required by Chrome
- background.service_worker - Uses the modern service worker approach instead of background pages
- content_scripts - Run at "document_idle" to ensure the page is fully loaded before injecting the panel
- action - Simple browser action with no popup, just toggles the panel on click
The extension consists of three main files:
- manifest.json: Configuration file that defines extension metadata, permissions, and behavior.
- background.js: Service worker that handles extension icon clicks and messaging.
- content.js: Content script that creates and manages the viewport panel.
Current Version: 1.0.1
- Message Passing: Uses Chrome's message passing system to communicate between background and content scripts.
- Event Handling: Efficiently manages browser events with debouncing for performance.
- DOM Manipulation: Creates and updates the panel using vanilla JavaScript.
- Error Handling: Comprehensive error catching and reporting.
The extension uses standard Tailwind CSS breakpoints:
| Breakpoint | Width (px) |
|---|---|
| none | < 640 |
| sm | β₯ 640 |
| md | β₯ 768 |
| lg | β₯ 1024 |
| xl | β₯ 1280 |
| 2xl | β₯ 1536 |
The extension includes comprehensive error handling:
- Validation: Input validation for all parameters and operations.
- Try-Catch Blocks: Wrapped around all critical operations.
- Console Logging: Descriptive error messages with 'Tailgunner:' prefix for easy identification.
- Graceful Degradation: Fails safely and cleans up resources when errors occur.
For developers, a debug mode can be enabled by setting DEBUG = true in content.js. When enabled, additional console messages will help trace execution flow and state changes during development.
- Clone the repository.
- Make your changes to the source files.
- Load the extension in developer mode to test.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Use modern JavaScript features.
- Include JSDoc comments for functions.
- Follow the existing error handling patterns.
- Maintain the same level of code quality.
The extension uses a private key (PEM file) for signing the CRX package. For security reasons:
- PEM files are ignored by git: All
.pemfiles are excluded via.gitignore - Never commit private keys: The private key should be kept secret and never shared in version control
- Automated build security: The build process uses GitHub Actions secrets for secure key management
-
Local Development: For local development, you can generate your own private key:
openssl genpkey -algorithm RSA -out chrome-extension.pem -pkeyopt rsa_keygen_bits:2048
-
CI/CD Pipeline: For the automated build process:
- The private key is stored as a base64-encoded GitHub secret (
CHROME_EXTENSION_PRIVATE_KEY_B64) - It's decoded during the build process to sign the CRX file
- To update this secret, encode your PEM file:
Then copy the contents to the GitHub repository secrets
base64 -i chrome-extension.pem > encoded_key.txt
- The private key is stored as a base64-encoded GitHub secret (
This project uses GitHub Actions to automate the build and release process:
- Version Check: When code is pushed to main, a script checks if the manifest version is newer than the latest tag
- Build Process: If a new version is detected, the workflow:
- Decodes the private key from GitHub secrets
- Builds the CRX package
- Creates a new tag matching the version number
- Creates a GitHub release with the CRX attached
To trigger a new release:
- Update the version in
manifest.json - Commit and push to main
- The GitHub Action will handle the rest automatically
- No Data Collection: This extension does not collect or transmit any user data.
- Local Processing: All functionality runs locally in your browser.
- Minimal Permissions: Uses only the permissions necessary for core functionality.
- No External Resources: Does not load any external scripts or resources.
This extension complies with Chrome Web Store policies by:
- Requesting minimal permissions: Only
activeTabpermission is required - Clear purpose: Functionality is focused and clearly described
- No data collection: Does not collect, store, or transmit user data
- No obfuscated code: All code is fully documented and transparently implemented
- No external libraries: Uses only vanilla JavaScript
- Consistent branding: Name and description are consistent and accurate
This project is licensed under the MIT License - see the LICENSE file for details.
- Tailwind CSS for their excellent CSS framework.
- All contributors who help improve this extension.
