« get me outta code hell

interactive-bgm - Browser extension that adds background music based on the site you're browsing
about summary refs log tree commit diff
path: root/extension/popup/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'extension/popup/main.js')
-rw-r--r--extension/popup/main.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/extension/popup/main.js b/extension/popup/main.js
index 1bf653a..1dc39f4 100644
--- a/extension/popup/main.js
+++ b/extension/popup/main.js
@@ -332,6 +332,11 @@ function loadRuleList({tab, siteSettings, selectRule}) {
 
     createRuleButton.appendChild(document.createTextNode('Create Rule'));
 
+    if (!new URL(tab.url).hostname) {
+        createRuleButton.disabled = true;
+        createRuleButton.title = `Sorry, this page doesn't appear to have a hostname. We can't create a rule here.`;
+    }
+
     createRuleButton.addEventListener('click', () => {
         const {hostnameParts} = getURLParts(tab.url);
         const rule = {