feat: Add initial Firefox container tab extension with popup UI, background script, manifest, and a comprehensive set of icons.
This commit is contained in:
192
popup/popup.css
Normal file
192
popup/popup.css
Normal file
@@ -0,0 +1,192 @@
|
||||
/* Container Bookmarks - Popup Styles */
|
||||
/* Firefox Photon Design System inspired */
|
||||
|
||||
:root {
|
||||
--background-color: #1c1b22;
|
||||
--surface-color: #2b2a33;
|
||||
--text-color: #fbfbfe;
|
||||
--text-secondary: #b1b1b3;
|
||||
--border-color: #3a3944;
|
||||
--primary-color: #00ddff;
|
||||
--danger-color: #ff6b6b;
|
||||
--hover-color: #3a3944;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
font-size: 13px;
|
||||
background-color: var(--background-color);
|
||||
color: var(--text-color);
|
||||
width: 320px;
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
.popup-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.header {
|
||||
padding: 16px;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
background: linear-gradient(135deg, #2b2a33 0%, #1c1b22 100%);
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
/* Content */
|
||||
.content {
|
||||
flex: 1;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.section h2 {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
/* Mappings List */
|
||||
.mappings-list {
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.mapping-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 10px;
|
||||
background-color: var(--surface-color);
|
||||
border-radius: 6px;
|
||||
margin-bottom: 6px;
|
||||
transition: background-color 0.15s ease;
|
||||
}
|
||||
|
||||
.mapping-item:hover {
|
||||
background-color: var(--hover-color);
|
||||
}
|
||||
|
||||
.container-indicator {
|
||||
width: 4px;
|
||||
height: 28px;
|
||||
border-radius: 2px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.mapping-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.bookmark-title {
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.container-name {
|
||||
font-size: 11px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.remove-btn {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.15s ease;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.remove-btn:hover {
|
||||
background-color: var(--danger-color);
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Empty/Loading States */
|
||||
.empty, .loading {
|
||||
text-align: center;
|
||||
color: var(--text-secondary);
|
||||
padding: 20px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* Tips */
|
||||
.tips {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.tips li {
|
||||
position: relative;
|
||||
padding-left: 16px;
|
||||
margin-bottom: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.tips li::before {
|
||||
content: '•';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
.footer {
|
||||
padding: 10px 16px;
|
||||
border-top: 1px solid var(--border-color);
|
||||
font-size: 11px;
|
||||
color: var(--text-secondary);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Scrollbar */
|
||||
.mappings-list::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.mappings-list::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.mappings-list::-webkit-scrollbar-thumb {
|
||||
background-color: var(--border-color);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.mappings-list::-webkit-scrollbar-thumb:hover {
|
||||
background-color: var(--text-secondary);
|
||||
}
|
||||
38
popup/popup.html
Normal file
38
popup/popup.html
Normal file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="popup.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="popup-container">
|
||||
<header class="header">
|
||||
<h1>Container Bookmarks</h1>
|
||||
</header>
|
||||
|
||||
<main class="content">
|
||||
<section class="section">
|
||||
<h2>Assigned Bookmarks</h2>
|
||||
<div id="mappings-list" class="mappings-list">
|
||||
<p class="loading">Loading...</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>Quick Tips</h2>
|
||||
<ul class="tips">
|
||||
<li>Right-click any bookmark to assign a container</li>
|
||||
<li>Assigned bookmarks auto-open in their container</li>
|
||||
<li>Container colors match Firefox's container tabs</li>
|
||||
</ul>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer class="footer">
|
||||
<span id="stats"></span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
125
popup/popup.js
Normal file
125
popup/popup.js
Normal file
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Container Bookmarks - Popup Script
|
||||
*/
|
||||
|
||||
const STORAGE_KEY = 'bookmark_container_mappings';
|
||||
|
||||
// Container color palette (matches Firefox)
|
||||
const CONTAINER_COLORS = {
|
||||
'blue': '#37adff',
|
||||
'turquoise': '#00c79a',
|
||||
'green': '#51cd00',
|
||||
'yellow': '#ffcb00',
|
||||
'orange': '#ff9f00',
|
||||
'red': '#ff613d',
|
||||
'pink': '#ff4bda',
|
||||
'purple': '#af51f5',
|
||||
'toolbar': '#7c7c7d'
|
||||
};
|
||||
|
||||
/**
|
||||
* Get all bookmark-container mappings
|
||||
*/
|
||||
async function getMappings() {
|
||||
const result = await browser.storage.local.get(STORAGE_KEY);
|
||||
return result[STORAGE_KEY] || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all containers
|
||||
*/
|
||||
async function getContainers() {
|
||||
try {
|
||||
return await browser.contextualIdentities.query({});
|
||||
} catch (error) {
|
||||
console.error('Failed to get containers:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a mapping
|
||||
*/
|
||||
async function removeMapping(bookmarkId) {
|
||||
const mappings = await getMappings();
|
||||
delete mappings[bookmarkId];
|
||||
await browser.storage.local.set({ [STORAGE_KEY]: mappings });
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the mappings list
|
||||
*/
|
||||
async function renderMappings() {
|
||||
const mappingsListEl = document.getElementById('mappings-list');
|
||||
const statsEl = document.getElementById('stats');
|
||||
|
||||
const mappings = await getMappings();
|
||||
const containers = await getContainers();
|
||||
const containerMap = {};
|
||||
containers.forEach(c => containerMap[c.cookieStoreId] = c);
|
||||
|
||||
const entries = Object.entries(mappings);
|
||||
|
||||
if (entries.length === 0) {
|
||||
mappingsListEl.innerHTML = '<p class="empty">No container assignments yet.<br>Right-click a bookmark to get started!</p>';
|
||||
statsEl.textContent = '0 bookmarks assigned';
|
||||
return;
|
||||
}
|
||||
|
||||
mappingsListEl.innerHTML = '';
|
||||
|
||||
for (const [bookmarkId, mapping] of entries) {
|
||||
try {
|
||||
const bookmarks = await browser.bookmarks.get(bookmarkId);
|
||||
if (!bookmarks || bookmarks.length === 0) {
|
||||
// Orphaned mapping, clean up
|
||||
await removeMapping(bookmarkId);
|
||||
continue;
|
||||
}
|
||||
|
||||
const bookmark = bookmarks[0];
|
||||
const container = containerMap[mapping.containerId];
|
||||
const containerColor = container ? CONTAINER_COLORS[container.color] || '#7c7c7d' : '#7c7c7d';
|
||||
const containerName = container ? container.name : mapping.containerName;
|
||||
|
||||
const item = document.createElement('div');
|
||||
item.className = 'mapping-item';
|
||||
item.innerHTML = `
|
||||
<div class="container-indicator" style="background-color: ${containerColor}"></div>
|
||||
<div class="mapping-info">
|
||||
<span class="bookmark-title" title="${bookmark.title}">${truncate(bookmark.title, 30)}</span>
|
||||
<span class="container-name">${containerName}</span>
|
||||
</div>
|
||||
<button class="remove-btn" data-bookmark-id="${bookmarkId}" title="Remove assignment">×</button>
|
||||
`;
|
||||
|
||||
mappingsListEl.appendChild(item);
|
||||
} catch (error) {
|
||||
// Bookmark doesn't exist, clean up
|
||||
await removeMapping(bookmarkId);
|
||||
}
|
||||
}
|
||||
|
||||
const validCount = mappingsListEl.children.length;
|
||||
statsEl.textContent = `${validCount} bookmark${validCount !== 1 ? 's' : ''} assigned`;
|
||||
|
||||
// Add click handlers for remove buttons
|
||||
document.querySelectorAll('.remove-btn').forEach(btn => {
|
||||
btn.addEventListener('click', async (e) => {
|
||||
const bookmarkId = e.target.dataset.bookmarkId;
|
||||
await removeMapping(bookmarkId);
|
||||
renderMappings();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate text with ellipsis
|
||||
*/
|
||||
function truncate(text, maxLength) {
|
||||
if (text.length <= maxLength) return text;
|
||||
return text.substring(0, maxLength - 1) + '…';
|
||||
}
|
||||
|
||||
// Initialize
|
||||
document.addEventListener('DOMContentLoaded', renderMappings);
|
||||
Reference in New Issue
Block a user