Download webgpu/extension/bg.js from PYTHAI/drAIML: direct link, hf CLI and curl.
- Browser
- Download file 977 Bytes
-
https://huggingface.co/spaces/PYTHAI/drAIML/resolve/main/webgpu/extension/bg.js
- Command line
-
hf download hf://spaces/PYTHAI/drAIML/webgpu/extension/bg.js
-
curl -L -o bg.js https://huggingface.co/spaces/PYTHAI/drAIML/resolve/main/webgpu/extension/bg.js
977 Bytes
| // 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(); | |
| }); | |