477a00db1a
Testing / remote-protocol-compat (0.9.5) (push) Successful in 48s
Testing / remote-protocol-compat (0.9.3) (push) Successful in 47s
Build & Publish Package / publish (push) Successful in 46s
Package Extension / package-extension (push) Successful in 59s
Testing / test (push) Failing after 50s
- Add a neutral WebExtension API adapter that uses Firefox browser.* or Chromium chrome.* without mutating globals. - Switch extension runtime code to the adapter and add Firefox-specific typings for tabs, windows, tab groups, storage, scripting, and native messaging ports. - Fix Firefox temporary add-on instructions to load the packaged manifest with background.scripts instead of the Chromium service worker manifest. - Detect Firefox in clients.list via runtime.getBrowserInfo and keep Chromium user-agent fallback support. - Make navigate.open wait briefly for Firefox to replace initial about:blank with the requested URL. - Add JS coverage for API selection, clients.list browser detection, and Firefox navigate.open URL polling. - Bump package and extension version to 0.15.2.
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { webExtApi as api } from '../browser-api';
|
|
// api.storage.local accessors for profile alias, window aliases, and sessions.
|
|
import type { SessionTab, StoredSession } from '../types';
|
|
|
|
export async function getProfileAlias(): Promise<string> {
|
|
const { profileAlias } = await api.storage.local.get<{ profileAlias?: string }>("profileAlias");
|
|
return profileAlias || "default";
|
|
}
|
|
|
|
export function getSessionTabs(session: StoredSession | undefined | null): SessionTab[] {
|
|
if (!session) return [];
|
|
if (Array.isArray(session.tabs)) {
|
|
return session.tabs
|
|
.map(entry => typeof entry === "string" ? { url: entry } : entry)
|
|
.filter(entry => entry?.url);
|
|
}
|
|
if (Array.isArray(session.urls)) {
|
|
return session.urls.filter(Boolean).map(url => ({ url }));
|
|
}
|
|
return [];
|
|
}
|
|
|
|
export async function getAliases(): Promise<Record<string, string>> {
|
|
const { windowAliases } = await api.storage.local.get<{ windowAliases?: Record<string, string> }>("windowAliases");
|
|
return windowAliases || {};
|
|
}
|
|
|
|
export async function getSessions(): Promise<Record<string, StoredSession>> {
|
|
const { sessions } = await api.storage.local.get<{ sessions?: Record<string, StoredSession> }>("sessions");
|
|
return sessions || {};
|
|
}
|