Commits

Rune Halvorsen committed 5ca1959

Deal with tabs that don't return a tab object. Don't use evt.origin for badge. Screwed with iframes or something

Comments (0)

Files changed (1)

extension/index.html

 }
 
 function toggleMood(evt) {
-    var url = window.opera.extension.tabs.getFocused().url;
+    var focused = window.opera.extension.tabs.getFocused();
+    if (!focused) { return }
+    var url = focused.url;
     var currentStatus = getPageStatus(url);
     var newStatus = null;
     if (currentStatus == "yay") {
 }
 
 function updateButton(url) {
-    url = url || window.opera.extension.tabs.getFocused().url;
-    var status = getPageStatus(url);
+    var status = "meh";
+    if (!url) {
+        var focused = window.opera.extension.tabs.getFocused();
+        if (focused) { url = focused.url }
+    }
+
+    if (url) {
+        var status = getPageStatus(url);
+    }
+
     if (status == "meh") {
         g_button.badge.display = "none";        
     }
 }
 
 function onConnectHandler(event) {
-    updateButton(event.origin);
+    updateButton();
 }
 
 function getPageStatus(url) {