// SPDX-License-Identifier: MIT // drAIML WebGPU helper · background. Opens the check once after install, shows the last verdict on the toolbar badge, // and opens the check when a drAIML page asks for it (content.js). const api = typeof browser !== "undefined" ? browser : chrome; const BADGE = { ready: ["✓", "#1f7a4d"], software: ["!", "#a15c00"], "no-adapter": ["!", "#a15c00"], missing: ["✕", "#a32222"], broken: ["✕", "#a32222"] }; const openCheck = () => api.tabs.create({ url: api.runtime.getURL("popup.html") }); api.runtime.onInstalled.addListener((d) => { if (d.reason === "install") openCheck(); }); api.runtime.onMessage.addListener((m) => { if (m && m.type === "verdict" && BADGE[m.verdict]) { const [text, color] = BADGE[m.verdict]; api.action.setBadgeText({ text }); api.action.setBadgeBackgroundColor({ color }); api.action.setTitle({ title: `WebGPU helper · ${m.verdict}` }); } else if (m && m.type === "open-check") openCheck(); });