change background.js into split typescript files for better managemand and build background.js from typescript
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
// @ts-nocheck
|
||||
import { getAliases } from '../core';
|
||||
export async function windowsList() {
|
||||
const windows = await chrome.windows.getAll({ populate: true });
|
||||
const aliases = await getAliases();
|
||||
return windows.map(w => ({
|
||||
id: w.id,
|
||||
alias: aliases[w.id] || null,
|
||||
focused: w.focused,
|
||||
state: w.state,
|
||||
tabCount: (w.tabs || []).length,
|
||||
}));
|
||||
}
|
||||
|
||||
export async function windowsRename({ windowId, name }) {
|
||||
const aliases = await getAliases();
|
||||
aliases[windowId] = name;
|
||||
await chrome.storage.local.set({ windowAliases: aliases });
|
||||
return { windowId, name };
|
||||
}
|
||||
|
||||
export async function windowsClose({ windowId }) {
|
||||
await chrome.windows.remove(windowId);
|
||||
return { windowId };
|
||||
}
|
||||
|
||||
export async function windowsOpen({ url }) {
|
||||
const createData = { focused: true };
|
||||
if (url) createData.url = url;
|
||||
const w = await chrome.windows.create(createData);
|
||||
return { id: w.id };
|
||||
}
|
||||
|
||||
// ── DOM / Extract ─────────────────────────────────────────────────────────────
|
||||
Reference in New Issue
Block a user