Yay a devtools!

This commit is contained in:
2025-02-15 12:46:14 -07:00
parent 8e6294c96f
commit 9124abb749
9 changed files with 303 additions and 0 deletions

24
devtools/background.js Normal file
View File

@@ -0,0 +1,24 @@
console.log("background.js loaded");
// Listen for messages from the devtools panel
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
// You could add a check to see if the message is from the devtools panel.
if (message.type === "GET_CONTEXT_STACK") {
// Forward the message to the content script running in the active tab.
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
if (tabs.length) {
browser.tabs.sendMessage(tabs[0].id, message).then(sendResponse);
}
});
// Return true to indicate you wish to send a response asynchronously
return true;
} else if (message.type === "UPDATE_CONTEXT_VALUE") {
// Forward update messages similarly
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
if (tabs.length) {
browser.tabs.sendMessage(tabs[0].id, message).then(sendResponse);
}
});
return true;
}
});