Skip to content

Commit 0edb72a

Browse files
committed
cleaner code
1 parent 4835a51 commit 0edb72a

File tree

1 file changed

+14
-29
lines changed

1 file changed

+14
-29
lines changed

packages/react-devtools-extensions/src/background.js

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,35 +90,20 @@ function doublePipe(one, two) {
9090
}
9191

9292
function setIconAndPopup(reactBuildType, tabId) {
93-
if (IS_FIREFOX) {
94-
chrome.browserAction.setIcon({
95-
tabId: tabId,
96-
path: {
97-
'16': chrome.runtime.getURL(`icons/16-${reactBuildType}.png`),
98-
'32': chrome.runtime.getURL(`icons/32-${reactBuildType}.png`),
99-
'48': chrome.runtime.getURL(`icons/48-${reactBuildType}.png`),
100-
'128': chrome.runtime.getURL(`icons/128-${reactBuildType}.png`),
101-
},
102-
});
103-
chrome.browserAction.setPopup({
104-
tabId: tabId,
105-
popup: chrome.runtime.getURL(`popups/${reactBuildType}.html`),
106-
});
107-
} else {
108-
chrome.action.setIcon({
109-
tabId: tabId,
110-
path: {
111-
'16': chrome.runtime.getURL(`icons/16-${reactBuildType}.png`),
112-
'32': chrome.runtime.getURL(`icons/32-${reactBuildType}.png`),
113-
'48': chrome.runtime.getURL(`icons/48-${reactBuildType}.png`),
114-
'128': chrome.runtime.getURL(`icons/128-${reactBuildType}.png`),
115-
},
116-
});
117-
chrome.action.setPopup({
118-
tabId: tabId,
119-
popup: chrome.runtime.getURL(`popups/${reactBuildType}.html`),
120-
});
121-
}
93+
const action = IS_FIREFOX ? chrome.browserAction : chrome.action;
94+
action.setIcon({
95+
tabId: tabId,
96+
path: {
97+
'16': chrome.runtime.getURL(`icons/16-${reactBuildType}.png`),
98+
'32': chrome.runtime.getURL(`icons/32-${reactBuildType}.png`),
99+
'48': chrome.runtime.getURL(`icons/48-${reactBuildType}.png`),
100+
'128': chrome.runtime.getURL(`icons/128-${reactBuildType}.png`),
101+
},
102+
});
103+
action.setPopup({
104+
tabId: tabId,
105+
popup: chrome.runtime.getURL(`popups/${reactBuildType}.html`),
106+
});
122107
}
123108

124109
function isRestrictedBrowserPage(url) {

0 commit comments

Comments
 (0)