Last Tab Focus is a Chrome extension focused on one thing: when you close the current tab, it brings focus back to the tab you were using just before it in the same window.
It is intentionally narrow in scope. It does not try to be a full tab manager. It only changes close behavior, and it keeps that behavior local to your browser session.
日本語: Chromeで今のタブを閉じると、同じウィンドウ内で右隣や左隣ではなく、直前まで使っていたタブへ戻る拡張機能です。閉じたタブを復元する機能ではありません。
- Last-used tab restore: Returns to the tab you were actually using, not simply the tab to the left or right
- Same-window behavior: Restores focus only within the same browser window
- Single-purpose behavior: No tab grouping, session management, or other broader tab features
- Small and local: No analytics, no remote services, and no external data transmission
Install the published extension from the Chrome Web Store listing if you want automatic updates:
Install Last Tab Focus from the Chrome Web Store
- Clone this repository:
git clone https://github.com/sakataka/last-tab-focus.git cd last-tab-focus - Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" in the top right
- Click "Load unpacked" and select the project directory
- The extension will be loaded and ready to use
- Open multiple tabs in Chrome
- Switch between tabs to build focus history
- Close an active tab (Ctrl+W / ⌘+W)
- The extension will automatically focus the last tab you were using in the same window
- If no valid history entry exists, Chrome keeps its default tab-selection behavior
- Manifest Version: 3 (latest Chrome extension standard)
- Permissions:
storageonly; the tab events used by the extension do not require the broadertabspermission - Architecture: Service Worker background script
- Session Storage:
chrome.storage.sessionkeeps in-memory history across service worker restarts - Minimum Chrome Version: 102
Run the lightweight regression test suite:
node --test history.test.mjsThen follow the manual checklist in TESTING.md to verify browser behavior.
- Go to
chrome://extensions/ - Find "Last Tab Focus" extension
- Click "service worker" inspection link
- View logs in the developer console
- Make your changes to the source code
- Test thoroughly using the regression tests and manual checklist
- Ensure no console errors in service worker
- Test in different scenarios (single window, multiple windows, many tabs)
MIT License - Feel free to use and modify as needed.
We welcome contributions! Please follow these steps:
- Check existing issues to avoid duplicates
- Use the issue template (if available)
- Include:
- Chrome version
- Extension version
- Steps to reproduce
- Expected vs actual behavior
- Console logs (if applicable)
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name
- Make your changes following the existing code style
- Test thoroughly:
- Run
node --test history.test.mjs - Follow
TESTING.md - Test with multiple tabs and windows
- Check service worker console for errors
- Run
- Commit your changes with clear messages
- Push to your fork and submit a pull request
- Follow the existing code style and structure
- Add comments for complex logic
- Include error handling for new features
- Maintain compatibility with Chrome 102+
- Keep the extension lightweight and fast
- Ensure your code passes all tests
- Update documentation if needed
- Keep PRs focused on a single feature/fix
- Describe what your PR does and why
- Reference any related issues
If you encounter any issues:
- Check the browser console for errors
- Review the service worker logs
- Try disabling and re-enabling the extension
- Create an issue with detailed reproduction steps