From aea6135586e3c64c2fe483ac67cef5906217dc80 Mon Sep 17 00:00:00 2001 From: Elbert Alias Date: Fri, 18 Apr 2014 07:59:30 +1000 Subject: [PATCH] Fixed Firefox panel links and tabs.js error --- drivers/firefox/data/js/panel.js | 20 +++++++++------ drivers/firefox/data/js/tab.js | 42 +++++++++++++++++--------------- drivers/firefox/package.json | 2 +- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/drivers/firefox/data/js/panel.js b/drivers/firefox/data/js/panel.js index e593c4f0d..694791549 100644 --- a/drivers/firefox/data/js/panel.js +++ b/drivers/firefox/data/js/panel.js @@ -27,11 +27,13 @@ a.setAttribute('href', '#'); - a.addEventListener('click', function(e) { - e.preventDefault(); + (function(appName) { + a.addEventListener('click', function(e) { + e.preventDefault(); - self.port.emit('goToUrl', 'applications/' + appName.toLowerCase().replace(/ /g, '-').replace(/[^\w-]/g, '')); - }); + self.port.emit('goToUrl', 'applications/' + appName.toLowerCase().replace(/ /g, '-').replace(/[^\w-]/g, '')); + }); + }(appName)); img.setAttribute('src', 'images/icons/' + appName + '.png'); img.setAttribute('height', '16'); @@ -58,11 +60,13 @@ a.setAttribute('href', '#'); - a.addEventListener('click', function(e) { - e.preventDefault(); + (function(appName) { + a.addEventListener('click', function(e) { + e.preventDefault(); - self.port.emit('goToUrl', 'categories/' + message.categories[cat]); - }); + self.port.emit('goToUrl', 'categories/' + message.categories[cat]); + }); + }(appName)); label.setAttribute('class', 'category'); diff --git a/drivers/firefox/data/js/tab.js b/drivers/firefox/data/js/tab.js index 78c0e61d7..18269eda5 100644 --- a/drivers/firefox/data/js/tab.js +++ b/drivers/firefox/data/js/tab.js @@ -1,31 +1,33 @@ (function() { var lastEnv = []; - if ( document.contentType === 'text/html' ) { - var - html = document.documentElement.outerHTML - env = []; + try { + if ( document && document.documentElement && document.contentType === 'text/html' ) { + var + html = document.documentElement.outerHTML + env = []; - self.port.emit('log', 'init'); + self.port.emit('log', 'init'); - if ( html.length > 50000 ) { - html = html.substring(0, 25000) + html.substring(html.length - 25000, html.length); - } - - self.port.emit('analyze', { - hostname: location.hostname, - url: location.href, - analyze: { html: html } - }); - - setTimeout(function() { - var env = Object.keys(unsafeWindow).slice(0, 500); + if ( html.length > 50000 ) { + html = html.substring(0, 25000) + html.substring(html.length - 25000, html.length); + } self.port.emit('analyze', { hostname: location.hostname, url: location.href, - analyze: { env: env } + analyze: { html: html } }); - }, 1000); - } + + setTimeout(function() { + var env = Object.keys(unsafeWindow).slice(0, 500); + + self.port.emit('analyze', { + hostname: location.hostname, + url: location.href, + analyze: { env: env } + }); + }, 1000); + } + } catch (e) { } }()); diff --git a/drivers/firefox/package.json b/drivers/firefox/package.json index e090f2d96..bc27918d4 100644 --- a/drivers/firefox/package.json +++ b/drivers/firefox/package.json @@ -8,7 +8,7 @@ "description": "Identifies software on the web", "author": "Elbert Alias", "license": "GPLv3", - "version": "3.0.4", + "version": "3.0.5", "main": "driver", "preferences": [{ "name": "tracking",