Documentation Index
Fetch the complete documentation index at: https://mintlify.com/adalidbori/Tab-Closer-Ext/llms.txt
Use this file to discover all available pages before exploring further.
Welcome Contributors!
Thank you for your interest in contributing to Tab Closer! This guide will help you get started with development, testing, and submitting contributions.Getting Started
Load Extension in Chrome
See the Development Setup section below
Development Setup
Loading the Extension Locally
Enable Developer Mode
- Open Chrome and navigate to
chrome://extensions/ - Toggle “Developer mode” ON in the top-right corner
Load Unpacked Extension
- Click “Load unpacked” button
- Select the directory containing the extension files (where
manifest.jsonis located)
After making code changes, click the refresh icon on the extension card in
chrome://extensions/ to reload the extension.Development Tools
You’ll need:- Chrome Browser: Version 88 or higher (for Manifest V3 support)
- Text Editor: VS Code, Sublime Text, or your preferred editor
- Git: For version control
- DevTools: Built into Chrome for debugging
No build process is required! This extension uses vanilla JavaScript and can be loaded directly.
Project Structure
Understanding the codebase organization:File Responsibilities
manifest.json - Configuration
manifest.json - Configuration
Defines extension metadata, permissions, and entry points. Modify this when:
- Adding new permissions
- Changing version number
- Adding new background scripts or content scripts
- Updating extension description or name
background.js - Core Logic
background.js - Core Logic
Service worker that runs in the background. This file:
- Listens for
chrome.tabs.onCreatedevents - Queries tab counts using
chrome.tabs.query() - Retrieves settings from
chrome.storage.local - Closes excess tabs using
chrome.tabs.remove()
popup.html - User Interface
popup.html - User Interface
The HTML structure for the extension popup. Contains:
- Toggle switch (flipswitch) for enabling/disabling
- Number input for setting tab limit
- Save button
- Success message
script.js - Popup Logic
script.js - Popup Logic
JavaScript for popup interactions. Handles:
- Loading saved settings on popup open
- Saving user settings to
chrome.storage.local - Input validation (minimum 2 tabs)
- Success message display
style.css - Styling
style.css - Styling
CSS for popup appearance. Includes:
- Custom toggle switch (flipswitch) styling
- Button styles
- Input field styles
- Layout and spacing
Development Workflow
Making Changes
Reload Extension
- Go to
chrome://extensions/ - Click the refresh icon on the Tab Closer card
- Or use Ctrl+R (Cmd+R on Mac) in the extensions page
Test Thoroughly
See Testing Your Changes section
Testing Your Changes
Manual Testing Checklist
- Popup loads correctly: Click extension icon, verify UI appears
- Settings persist: Configure settings, close popup, reopen to verify values saved
- Toggle works: Test ON and OFF states
- Tab limit enforced: Open multiple tabs, verify oldest tabs close when limit exceeded
- Minimum validation: Try setting tab limit to 1 or 0, verify alert appears
- No console errors: Check DevTools console for both service worker and popup
- Edge cases: Test with exactly 2 tabs, test with many tabs (50+)
Debugging the Service Worker
background.js
- Navigate to
chrome://extensions/ - Click “Inspect views: service worker”
- Check the Console tab
Debugging the Popup
script.js
- Open the extension popup
- Right-click inside popup → Inspect
- Check the Console tab
Code Style Guidelines
JavaScript Style
Naming Conventions
Naming Conventions
- Use
camelCasefor variables and functions:tabsallow,save() - Use descriptive names:
cantidadTabsis clear,ctis not - Use
constfor constants,letfor variables that change
Code Formatting
Code Formatting
- Indent with 2 or 4 spaces (be consistent)
- Add spaces around operators:
if (tabs.length > cantidadTabs) - Use semicolons at end of statements
- Add comments for complex logic
Error Handling
Error Handling
- Always wrap Chrome API calls that might fail in try-catch
- Log errors to console for debugging
HTML/CSS Style
- Use semantic HTML elements
- Keep inline styles minimal (use CSS classes instead)
- Maintain consistent indentation
- Use descriptive class names:
.flipswitchnot.fs
Common Development Tasks
Adding a New Setting
Improving the Tab Closing Logic
The current implementation inbackground.js closes the oldest tabs (lowest indices). To change this behavior:
background.js
Consider making the closing strategy a user-configurable option!
Refactoring Nested Callbacks
The currentbackground.js uses nested callbacks. Consider refactoring to async/await:
background.js
Chrome Extension APIs support Promises as of Chrome 88+, making async/await available.
Feature Ideas & Improvements
Looking for contribution ideas? Consider these enhancements:Priority Improvements
Add tab whitelist feature
Add tab whitelist feature
Allow users to whitelist certain domains that should never be closed:
- Add domain input field in popup
- Store whitelist in
chrome.storage.local - Check tab URL before closing in background.js
- Use
chrome.tabspermission to accesstab.url
Improve tab closing strategy
Improve tab closing strategy
Instead of always closing oldest tabs:
- Add option to close by last accessed time
- Add option to close duplicates first
- Add option to never close pinned tabs
- Make strategy user-configurable
Internationalization (i18n)
Internationalization (i18n)
The UI currently has Spanish text mixed with English:
- Implement
chrome.i18nAPI - Create
_locales/directory with translations - Support multiple languages
- Update popup.html to use
chrome.i18n.getMessage()
Statistics and reporting
Statistics and reporting
Track and display tab closing statistics:
- Count tabs closed per day/week
- Show most commonly closed domains
- Display in popup or separate page
- Store in
chrome.storage.local
Improved error handling
Improved error handling
- Add user-visible error messages
- Handle edge cases (all pinned tabs, protected tabs)
- Add retry logic for failed API calls
- Log errors to storage for debugging
UI/UX Improvements
- Add dark mode support
- Improve toggle switch accessibility
- Add keyboard shortcuts
- Show preview of which tabs would be closed
- Add undo functionality
- Improve success message animation
Code Quality
- Refactor nested callbacks to async/await
- Add JSDoc comments
- Create unit tests
- Add ESLint configuration
- Remove commented-out code
- Improve variable naming (e.g.,
fs→isEnabled,cantidadTabs→tabLimit)
Submission Guidelines
Before Submitting a PR
Pull Request Template
When opening a PR, include:Code Review Process
After submitting:- Automated checks: Ensure any CI checks pass
- Maintainer review: A project maintainer will review your code
- Feedback: Address any requested changes
- Approval: Once approved, your PR will be merged
- Release: Changes will be included in the next release
Be patient! Maintainers review PRs in their spare time. Expect 1-7 days for initial review.
Chrome Web Store Publishing
For maintainers, the publishing process:Update Version
Increment version in
manifest.json following semantic versioningUpload to Chrome Web Store Developer Dashboard
Navigate to Chrome Web Store Developer Dashboard
Getting Help
If you need assistance:- Documentation: Review the Technical Architecture page
- Issues: Check existing GitHub issues for similar problems
- Questions: Open a GitHub issue with the “question” label
- Chrome Extension Docs: Official Chrome Extension Documentation
Code of Conduct
- Be respectful and inclusive
- Provide constructive feedback
- Focus on the code, not the person
- Help others learn and grow
- Follow project guidelines
License
By contributing, you agree that your contributions will be licensed under the same license as the project.Thank you for contributing to Tab Closer! Your efforts help make the web browsing experience better for everyone.