feat: initialise Lildra browser extension
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
async function toggleLildra(tab) {
|
||||
if (!tab?.id) return;
|
||||
|
||||
try {
|
||||
await chrome.scripting.executeScript({
|
||||
target: { tabId: tab.id },
|
||||
files: ["lildra.js"]
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn("Lildra could not run on this page:", error);
|
||||
}
|
||||
}
|
||||
|
||||
chrome.action.onClicked.addListener(toggleLildra);
|
||||
chrome.commands.onCommand.addListener(async (command) => {
|
||||
if (command !== "toggle-lildra") return;
|
||||
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
||||
await toggleLildra(tab);
|
||||
});
|
||||
Reference in New Issue
Block a user