Yay a devtools!
This commit is contained in:
24
devtools/background.js
Normal file
24
devtools/background.js
Normal 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;
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user