Girlfriend’s Mad: The Page Just Vanished? I Hit the One-Click Restore Button!
“Regret Medicine” — A Chrome Extension to Instantly Restore Closed Tabs
> Scenario:
> Your girlfriend accidentally closes your tabs.
> You suggest: Ctrl/Cmd+Shift+T — she asks: “Where’s that key?!”
>
> You point to browsing history — she says: “Only shows today’s pages!”
>
> The “Recently Closed” menu? “Only 8 tabs — not enough!”
>
> ✅ Solution: Build a Chrome extension — Regret Medicine.
> One click to view recently closed tabs, restore one or all, with favicons and close times. Smooth animations, open-source, customizable.
---
Demo
Open popup → restore single → restore all

---
✨ Features
- List up to 25 recently closed tabs
- Restore individual tabs or restore all
- Show favicon, title, URL, close time
- Smooth animations
- Minimal permissions (`sessions`, `tabs`, `favicon`) and no background processes
---
⚙️ Core Implementation
Uses three Chrome APIs:
// Get recently closed tabs
chrome.sessions.getRecentlyClosed({ maxResults: 25 }, (sessions) => {});
// Restore a specific tab
chrome.sessions.restore(sessionId, (restoredSession) => {});
// Get favicon URL
function getFaviconURL(url) {
const faviconUrl = new URL(chrome.runtime.getURL('/_favicon/'));
faviconUrl.searchParams.set('pageUrl', url);
faviconUrl.searchParams.set('size', '16');
return faviconUrl.toString();
}Reference:
---
🔄 Data Recovery Flow
- User clicks Restore
- Runs `chrome.sessions.restore(sessionId)`
- Chrome finds session record
- Creates new tab with original URL
- Executes callback for success/fail
- UI removes restored item
---
📂 Project Structure
recently-closed-tabs
├─ manifest.json
├─ popup.html
├─ styles.css
└─ popup.js---
📝 Step-by-Step Installation
- Create folder `recently-closed-tabs`
- Create `manifest.json` — defines metadata, permissions
{
"manifest_version": 3,
"name": "Recently Closed Tabs Manager",
"version": "1.0",
"description": "View and restore recently closed tabs",
"permissions": ["sessions", "tabs", "favicon"],
"action": {
"default_popup": "popup.html",
"default_title": "Recently Closed Tabs"
}
}Key Fields
| Field | Purpose |
|-------|---------|
| `manifest_version: 3` | Latest spec for better security/performance |
| `name` | Toolbar/store display name |
| `version` | Extension version (semantic) |
| `description` | Short function description |
| `permissions` | API access:
• `sessions` → recently closed tabs
• `tabs` → restore tabs
• `favicon` → display icons |
| `action` | Toolbar icon behavior and popup page |
---
📄 Create `popup.html`
Recently Closed
0 tabs
Restore All
---
💻 Create `popup.js`
Handles DOM loading, listing recently closed tabs, restoring individually or all:
const elements = {
tabList: document.getElementById('tabList'),
restoreAllBtn: document.getElementById('restoreAllBtn'),
tabCount: document.getElementById('tabCount'),
};
const CONFIG = {
MAX_TABS: 25,
MESSAGES: {
EMPTY: 'No recently closed tabs found',
RESTORED: 'All tabs have been restored',
},
};
function init() {
loadRecentlyClosedTabs();
elements.restoreAllBtn.addEventListener('click', restoreAllTabs);
}
function loadRecentlyClosedTabs() {
chrome.sessions.getRecentlyClosed({ maxResults: CONFIG.MAX_TABS }, (sessions) => {
const tabs = sessions.filter(s => s.tab).map(s => ({
id: s.tab.sessionId,
title: s.tab.title || 'Untitled',
url: s.tab.url,
closedTime: s.lastModified * 1000,
}));
updateTabCount(tabs.length);
renderTabList(tabs);
});
}
...
document.addEventListener('DOMContentLoaded', init);---
🎨 Create `styles.css`
Responsive, animated UI styling for popup and tab list.
html,
body {
width: 440px;
height: 600px;
font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.header {
background: rgba(255,255,255,0.8);
padding: 20px;
}
.restore-all {
background: #007aff;
color: white;
border-radius: 18px;
}
.tab-item {
display: flex;
align-items: center;
padding: 12px;
background: #f9f9f9;
}---
🛠 Installation in Developer Mode
- Open Chrome → `chrome://extensions/`
- Enable Developer mode (top-right)
- Click Load unpacked
- Select `recently-closed-tabs` folder
- Pin extension, click icon to open popup


---
📖 Usage
- Popup lists recently closed tabs
- Click a tab to restore
- Click Restore All to reopen all
- Empty list shows “No recently closed tabs”
---
❓ FAQ
- No records? Must have recently closed tabs; after Chrome restart records may clear.
- Change number shown? Edit `CONFIG.MAX_TABS` in `popup.js` (max 25).
---
🔐 Privacy & Permissions
- No data collection
- Runs locally via `chrome.sessions` API
- Requires minimal permissions
---
📎 Links & Source
- Repo: GitHub — recently-closed-tabs
- Article: Read Original
- Open in WeChat
---
With this clean structure and headings, you now have a clear, readable developer guide for building and installing the “Regret Medicine” extension.