diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..59ba236 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: + - repo: https://github.com/codingjoe/esupgrade + rev: 2025.9.0 + hooks: + - id: esupgrade + diff --git a/chrome-extension/content.js b/chrome-extension/content.js index a2df91b..c6bc515 100644 --- a/chrome-extension/content.js +++ b/chrome-extension/content.js @@ -1,43 +1,35 @@ -(function() { - 'use strict'; +const STORAGE_KEY = 'django-devbar-show-bar'; +let currentShowState = true; +let styleElement = null; - if (typeof chrome === 'undefined' || !chrome.storage) { - return; +function injectHideCSS() { + if (!styleElement) { + styleElement = document.createElement('style'); + styleElement.id = 'devbar-visibility-control'; + styleElement.textContent = '#django-devbar { display: none !important; }'; + (document.head || document.documentElement).appendChild(styleElement); } +} - const STORAGE_KEY = 'django-devbar-show-bar'; - let currentShowState = true; - let styleElement = null; - - function injectHideCSS() { - if (!styleElement) { - styleElement = document.createElement('style'); - styleElement.id = 'devbar-visibility-control'; - styleElement.textContent = '#django-devbar { display: none !important; }'; - (document.head || document.documentElement).appendChild(styleElement); - } - } - - function removeHideCSS() { - if (styleElement && styleElement.parentNode) { - styleElement.parentNode.removeChild(styleElement); - styleElement = null; - } +function removeHideCSS() { + if (styleElement?.parentNode) { + styleElement.parentNode.removeChild(styleElement); + styleElement = null; } +} - function checkAndApply() { - chrome.storage.local.get([STORAGE_KEY], (result) => { - currentShowState = result[STORAGE_KEY] !== false; - currentShowState ? removeHideCSS() : injectHideCSS(); - }); - } +function checkAndApply() { + chrome.storage.local.get([STORAGE_KEY], (result) => { + currentShowState = result[STORAGE_KEY] !== false; + currentShowState ? removeHideCSS() : injectHideCSS(); + }); +} - checkAndApply(); +checkAndApply(); - chrome.storage.onChanged.addListener((changes, area) => { - if (area === 'local' && changes[STORAGE_KEY]) { - currentShowState = changes[STORAGE_KEY].newValue; - currentShowState ? removeHideCSS() : injectHideCSS(); - } - }); -})(); +chrome.storage.onChanged.addListener((changes, area) => { + if (area === 'local' && changes[STORAGE_KEY]) { + currentShowState = changes[STORAGE_KEY].newValue; + currentShowState ? removeHideCSS() : injectHideCSS(); + } +}); diff --git a/chrome-extension/devtools.js b/chrome-extension/devtools.js index 71906c6..23c0092 100644 --- a/chrome-extension/devtools.js +++ b/chrome-extension/devtools.js @@ -2,5 +2,5 @@ chrome.devtools.panels.create( 'Django DevBar', 'icons/icon16.png', 'panel.html', - function(panel) {} + panel => {} ); diff --git a/chrome-extension/panel.html b/chrome-extension/panel.html index 269974d..7054c5f 100644 --- a/chrome-extension/panel.html +++ b/chrome-extension/panel.html @@ -79,6 +79,6 @@
- +