fix(scripts): background wrong performance
This commit is contained in:
parent
dd6f6c9974
commit
7a45974e98
@ -207,8 +207,6 @@ const updateCache = (hostname, state) => {
|
|||||||
chrome.storage.local.get(null, (cache) => {
|
chrome.storage.local.get(null, (cache) => {
|
||||||
const current = cache[hostname];
|
const current = cache[hostname];
|
||||||
|
|
||||||
if (!state.enabled) report();
|
|
||||||
|
|
||||||
chrome.storage.local.set({
|
chrome.storage.local.set({
|
||||||
[hostname]: {
|
[hostname]: {
|
||||||
enabled:
|
enabled:
|
||||||
@ -228,25 +226,18 @@ chrome.runtime.onMessage.addListener((request, sender, callback) => {
|
|||||||
const hasPermission = !sender.frameId || sender.frameId === 0;
|
const hasPermission = !sender.frameId || sender.frameId === 0;
|
||||||
let tabId = sender.tab ? sender.tab.id : undefined;
|
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) {
|
switch (request.type) {
|
||||||
case "DISABLE_ICON":
|
case "DISABLE_ICON":
|
||||||
if (hasPermission) disableIcon(tabId);
|
if (hasPermission && tabId) disableIcon(tabId);
|
||||||
break;
|
break;
|
||||||
case "DISABLE_POPUP":
|
case "DISABLE_POPUP":
|
||||||
if (hasPermission) disablePopup(tabId);
|
if (hasPermission && tabId) disablePopup(tabId);
|
||||||
break;
|
break;
|
||||||
case "ENABLE_ICON":
|
case "ENABLE_ICON":
|
||||||
if (hasPermission) enableIcon(tabId);
|
if (hasPermission && tabId) enableIcon(tabId);
|
||||||
break;
|
break;
|
||||||
case "ENABLE_POPUP":
|
case "ENABLE_POPUP":
|
||||||
if (hasPermission) enablePopup(tabId);
|
if (hasPermission && tabId) enablePopup(tabId);
|
||||||
break;
|
break;
|
||||||
case "GET_CACHE":
|
case "GET_CACHE":
|
||||||
getCache(request.hostname, callback);
|
getCache(request.hostname, callback);
|
||||||
|
Loading…
Reference in New Issue
Block a user