Skip to content

Commit

Permalink
fix(scripts): wrong background script performance
Browse files Browse the repository at this point in the history
  • Loading branch information
wanhose committed Jul 1, 2021
1 parent b54a460 commit 5d5d295
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,14 @@ const updateState = (tabId, state) => {

chrome.runtime.onMessage.addListener((request, sender, responseCallback) => {
const hasPermission = !sender.frameId || sender.frameId === 0;
const tabId = sender.tab.id;
let tabId = sender.tab ? sender.tab.id : undefined;

if (!tabId) {
chrome.tabs.query(
{ active: true, currentWindow: true },
(tabs) => (tabId = tabs[0] ? tabs[0].id : 0)
);
}

switch (request.type) {
case "DISABLE_ICON":
Expand Down

0 comments on commit 5d5d295

Please sign in to comment.