Build Your Own Chrome Extension: Stackify Tabs – Organize Tabs by Domain (with Dark Mode!)
Stackify Your Tabs
πDo your browser tabs feel like a chaotic jungle? Ever wish you could sort them by domain and see what’s open at a glance? In this blog, I’ll walk you through building Stackify Tab – a lightweight Chrome extension that organizes tabs by website and even includes a dark mode toggle.
π§ Why Build a Tab Organizer?
As developers (or just power users), we open dozens of tabs – docs, tools, dashboards, and cat memes. Over time, it becomes hard to track them. This extension solves that by grouping tabs based on their domain name.
π What We’re Building
-
A popup that shows your open tabs, grouped by domain
-
Click to activate any tab directly
-
A Dark Mode switch to soothe your eyes during late-night coding
-
Super clean UI with rounded corners and smooth styling
π§ Step 1: Set Up the Extension
Create a folder named stackify-extension, and inside it, add these files:
π Folder Structure
Let’s break down what’s happening inside your Chrome extension:
π¦ manifest.json
This file tells Chrome what your extension is and what permissions it needs:
"tabs"permission lets the extension read information about open browser tabs."default_popup"points to the UI (popup.html) users will see when they click the extension icon.- It also sets up the icon for the extension toolbar.
π popup.html
This is the mini web page that appears when you click the extension icon. It includes:
- A header (
<h2>) with the extension name. - A Dark Mode toggle using a checkbox + custom slider.
- An empty
div(#tabList) that gets populated dynamically with tab info from JavaScript.
π¨ styles.css
The stylesheet defines how the popup looks:
- Light and dark theme colors using CSS variables.
- Rounded corners, soft shadows, clean typography.
- The toggle switch is custom styled with animation.
- Responsive layout for grouped domain names and tabs.
π§ popup.js
Here’s where the magic happens:
- First, it checks the saved dark mode preference from local storage and applies the correct theme.
- It uses
chrome.tabs.query()to get all current tabs. - Tabs are grouped by domain, so you can see how many tabs are open from the same site.
- Clicking a tab title brings it into focus in your browser!
π Bonus: Dark Mode Feature
Users can toggle between light and dark mode. The setting is remembered even after the popup is closed, thanks to localStorage. It's a small touch that adds polish and modern UX!
Comments
Post a Comment