Skip to content

Commit 2bae156

Browse files
committed
only get JSON resource when inspected tab updates
1 parent 5b2761f commit 2bae156

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

background.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Can use:
44
// chrome.tabs.*
55
// chrome.extension.*
6-
6+
var tabInspected;
77
var ports = [];
88
chrome.runtime.onConnect.addListener(function (port) {
99
if (port.name !== "devtools") return;
@@ -19,15 +19,16 @@ chrome.runtime.onConnect.addListener(function (port) {
1919
});
2020

2121
chrome.tabs.onUpdated.addListener(function (tabId, changes, tabObject) {
22-
if (changes.status == "complete") {
22+
if (tabId == tabInspected && changes.status == "complete") {
2323
getJsonResource(tabId);
2424
}
2525
});
2626

2727
function processBackgroundIncomingMessage(msg) {
2828
console.log("Processing Message in Background", msg)
2929
if (msg.tabId) {
30-
getJsonResource(msg.tabId);
30+
tabInspected = msg.tabId;
31+
getJsonResource(tabInspected);
3132
} else {
3233
console.log(msg);
3334
}
@@ -57,7 +58,7 @@ function getJsonResource(tabID) {
5758
notifyDevtools(JSON.parse('{"error":"' + e + '"}'));
5859
}
5960
} else {
60-
notifyDevtools(JSON.parse('{"error":"No Solidus Page Context Found"}'));
61+
notifyDevtools(JSON.parse('{"error":"No Solidus Page Context Found!"}'));
6162
}
6263
}
6364
}

0 commit comments

Comments
 (0)