mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-20 11:03:07 +00:00
feat: add cross-browser extension with AI reading assistant
- Create Pi Reader browser extension for Chrome/Firefox - Chrome uses Side Panel API, Firefox uses Sidebar Action API - Supports both browsers with separate manifests and unified codebase - Built with mini-lit components and Tailwind CSS v4 - Features model selection dialog with Ollama support - Hot reload development server watches both browser builds - Add useDefineForClassFields: false to fix LitElement reactivity
This commit is contained in:
parent
c1185c7b95
commit
b67c10dfb1
33 changed files with 4453 additions and 1202 deletions
23
packages/browser-extension/src/background.ts
Normal file
23
packages/browser-extension/src/background.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Declare browser global for Firefox
|
||||
declare const browser: any;
|
||||
|
||||
// Detect browser type
|
||||
const isFirefox = typeof browser !== "undefined" && typeof browser.runtime !== "undefined";
|
||||
const browserAPI = isFirefox ? browser : chrome;
|
||||
|
||||
// Open side panel/sidebar when extension icon is clicked
|
||||
browserAPI.action.onClicked.addListener((tab: chrome.tabs.Tab) => {
|
||||
if (isFirefox) {
|
||||
// Firefox: Toggle the sidebar
|
||||
if (typeof browser !== "undefined" && browser.sidebarAction) {
|
||||
browser.sidebarAction.toggle();
|
||||
}
|
||||
} else {
|
||||
// Chrome: Open the side panel
|
||||
if (tab.id && chrome.sidePanel) {
|
||||
chrome.sidePanel.open({ tabId: tab.id });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export {};
|
||||
Loading…
Add table
Add a link
Reference in a new issue