« get me outta code hell

Disallow creating rules on no-hostname pages - interactive-bgm - Browser extension that adds background music based on the site you're browsing
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-03-24 10:41:25 -0300
committerFlorrie <towerofnix@gmail.com>2019-03-24 10:41:25 -0300
commit895619545e629b8c03d09f8685e2aa71f84aa92a (patch)
tree64418f317b7d512b8f8f725c4e0f6471344f3d94
parent6f5e2d9b568504b681bcfaf3405d059b900bb4b1 (diff)
Disallow creating rules on no-hostname pages
-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 = {