Skip to content

Commit b04a732

Browse files
committed
Drop IIFEs and strict mode
They are obsolete in ESM.
1 parent 597ccf6 commit b04a732

File tree

3 files changed

+279
-291
lines changed

3 files changed

+279
-291
lines changed

chrome-extension/content.js

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,35 @@
1-
((() => {
2-
'use strict';
1+
const STORAGE_KEY = 'django-devbar-show-bar';
2+
let currentShowState = true;
3+
let styleElement = null;
34

4-
if (typeof chrome === 'undefined' || !chrome.storage) {
5-
return;
5+
function injectHideCSS() {
6+
if (!styleElement) {
7+
styleElement = document.createElement('style');
8+
styleElement.id = 'devbar-visibility-control';
9+
styleElement.textContent = '#django-devbar { display: none !important; }';
10+
(document.head || document.documentElement).appendChild(styleElement);
611
}
12+
}
713

8-
const STORAGE_KEY = 'django-devbar-show-bar';
9-
let currentShowState = true;
10-
let styleElement = null;
11-
12-
function injectHideCSS() {
13-
if (!styleElement) {
14-
styleElement = document.createElement('style');
15-
styleElement.id = 'devbar-visibility-control';
16-
styleElement.textContent = '#django-devbar { display: none !important; }';
17-
(document.head || document.documentElement).appendChild(styleElement);
18-
}
19-
}
20-
21-
function removeHideCSS() {
22-
if (styleElement?.parentNode) {
23-
styleElement.parentNode.removeChild(styleElement);
24-
styleElement = null;
25-
}
14+
function removeHideCSS() {
15+
if (styleElement?.parentNode) {
16+
styleElement.parentNode.removeChild(styleElement);
17+
styleElement = null;
2618
}
19+
}
2720

28-
function checkAndApply() {
29-
chrome.storage.local.get([STORAGE_KEY], (result) => {
30-
currentShowState = result[STORAGE_KEY] !== false;
31-
currentShowState ? removeHideCSS() : injectHideCSS();
32-
});
33-
}
21+
function checkAndApply() {
22+
chrome.storage.local.get([STORAGE_KEY], (result) => {
23+
currentShowState = result[STORAGE_KEY] !== false;
24+
currentShowState ? removeHideCSS() : injectHideCSS();
25+
});
26+
}
3427

35-
checkAndApply();
28+
checkAndApply();
3629

37-
chrome.storage.onChanged.addListener((changes, area) => {
38-
if (area === 'local' && changes[STORAGE_KEY]) {
39-
currentShowState = changes[STORAGE_KEY].newValue;
40-
currentShowState ? removeHideCSS() : injectHideCSS();
41-
}
42-
});
43-
}))();
30+
chrome.storage.onChanged.addListener((changes, area) => {
31+
if (area === 'local' && changes[STORAGE_KEY]) {
32+
currentShowState = changes[STORAGE_KEY].newValue;
33+
currentShowState ? removeHideCSS() : injectHideCSS();
34+
}
35+
});

chrome-extension/panel.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@
7979
</label>
8080
</div>
8181
<div id="app"></div>
82-
<script src="panel.js"></script>
82+
<script type="module" src="panel.js"></script>
8383
</body>
8484
</html>

0 commit comments

Comments
 (0)