diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ce718f..f38384c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - IPV6 support - Language support for 'de','en','es','fr','ja','pt-BR','ru','zh-CN' -- What3Words, see README for adding and API key +- What3Words, gets the 3 words for the geo of the sender +- Forecast.IO, gets the weather from the sender, API key needs to be added in preferences ### Fixed - Fix mismatch IP from Microsoft SMTP id in received header \ No newline at end of file diff --git a/README.md b/README.md index 01613de..da91e41 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,29 @@ -# MailHops ![MailHops](chrome/content/images/mailhops32.png) Postbox Plugin +# MailHops Postbox Plugin +[www.MailHops.com](http://www.mailhops.com) + +MailHops logo + +MailHops is an email route API. It does two things: + +1. Returns a route an email took based on the Received header IP addresses +2. Returns a map an email took based on the Received header IP addresses + +The route will contain DNSBL lookup results, hostname lookup results and What3Words geo locations. 1. Edit files 2. Run [build.sh](build.sh) script 3. Open Postbox and goto Tools->Add-ons and "Install Add-on From File..." 4. Choose mailhops.xpi from build script -```bash +```sh $ chmod +x build.sh $ ./build.sh ``` + +## API +Host your own API +- [API](https://github.com/avantassel/mailhops-api) + +## Plugins +- [Postbox](https://github.com/avantassel/mailhops-postbox) +- [Thunderbird](https://github.com/avantassel/mailhops-thunderbird) \ No newline at end of file diff --git a/chrome/content/images/w3w.png b/chrome/content/images/w3w.png index 2bd4550..9ceef7e 100644 Binary files a/chrome/content/images/w3w.png and b/chrome/content/images/w3w.png differ diff --git a/chrome/content/mailhops.js b/chrome/content/mailhops.js index 795f756..d757c32 100644 --- a/chrome/content/mailhops.js +++ b/chrome/content/mailhops.js @@ -9,6 +9,7 @@ var mailHops = msgURI: null, resultTextDataPane: null, resultTextDataPane2: null, + resultTextDataPane3: null, resultContainerDataPane: null, resultDetailsLink: null, resultContainerDetails: null, @@ -46,6 +47,7 @@ mailHops.init = function() mailHops.resultContainerDataPane = document.getElementById ( "mailhopsDataPane"); mailHops.resultTextDataPane = document.getElementById ( "mailhopsDataPaneText"); mailHops.resultTextDataPane2 = document.getElementById ( "mailhopsDataPaneText2"); + mailHops.resultTextDataPane3 = document.getElementById ( "mailhopsDataPaneText3"); mailHops.resultDetailsLink = document.getElementById ( "mailhopsDataPaneDetailsLink"); mailHops.resultContainerDetails = document.getElementById ( "mailhopsDetailsContainer"); @@ -105,6 +107,7 @@ mailHops.loadPref = function() //get preferences mailHops.options.lan = mailHops.getCharPref('mail.mailHops.lang','en'); mailHops.options.unit = mailHops.getCharPref('mail.mailHops.unit','mi'); + mailHops.options.fkey = mailHops.getCharPref('mail.mailHops.fkey','');//forecast.io api_key //Display Boxes mailHops.options.show_details = mailHops.getCharPref('mail.mailHops.show_details','true')=='true'?true:false; @@ -122,18 +125,12 @@ mailHops.loadPref = function() mailHops.options.show_mailer = mailHops.getCharPref('mail.mailHops.show_mailer','true')=='true'?true:false; mailHops.options.show_dnsbl = mailHops.getCharPref('mail.mailHops.show_dnsbl','true')=='true'?true:false; - //Hosting - mailHops.options.use_private = mailHops.getCharPref('mail.mailHops.use_private','false')=='true'?true:false; - mailHops.options.hosting = mailHops.getCharPref('mail.mailHops.hosting','personal'); mailHops.options.debug = mailHops.getCharPref('mail.mailHops.debug','false')=='true'?true:false; mailHops.options.client_location = mailHops.getCharPref('mail.mailHops.client_location',''); - if(mailHops.options.use_private) - mailHops.options.api_url = mailHops.getCharPref('mail.mailHops.api_url','http://api.mailhops.com'); - else - mailHops.options.api_url='http://api.mailhops.com'; - + mailHops.options.api_url = mailHops.getCharPref('mail.mailHops.api_url','http://api.mailhops.com'); + if(mailHops.options.client_location == ''){ mailHops.setClientLocation(); } @@ -573,14 +570,15 @@ mailHops.authExplainDNSBL_server = function(result){ }; mailHops.displayResult = function ( header_route, response, meta, lookup_url ){ - var displayText=''; - var distanceText=''; - var image='chrome://mailhops/content/images/local.png'; - var city; - var state; - var countryName; - var gotFirst=false; - var secureToolTipText=false; + var displayText='' + , distanceText='' + , image='chrome://mailhops/content/images/local.png' + , city=null + , state=null + , countryName=null + , gotFirst=false + , secureToolTipText=false + , weather=null; //remove child details while(mailHops.resultDetails.firstChild) { @@ -639,13 +637,13 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){ if(response.route[i].city && response.route[i].state){ label.setAttribute('value','Hop #'+(i+1)+' '+response.route[i].city+', '+response.route[i].state); label.setAttribute('onclick','mailHops.launchWhoIs("'+response.route[i].ip+'");'); - } - else if(response.route[i].countryName){ - label.setAttribute('value','Hop #'+(i+1)+' '+response.route[i].countryName); - label.setAttribute('onclick','mailHops.launchWhoIs("'+response.route[i].ip+'");'); - } - else - label.setAttribute('value','Hop #'+(i+1)+' Private'); + } + else if(response.route[i].countryName){ + label.setAttribute('value','Hop #'+(i+1)+' '+response.route[i].countryName); + label.setAttribute('onclick','mailHops.launchWhoIs("'+response.route[i].ip+'");'); + } + else + label.setAttribute('value','Hop #'+(i+1)+' Private'); //build tooltip var tiptext = response.route[i].ip; @@ -664,6 +662,11 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){ //append details mailHops.resultDetails.appendChild(label); + //append weather + if(!weather && response.route[i].weather){ + weather = response.route[i].weather; + } + if(mailHops.options.show_secure){ //reset the tooltip secureToolTipText=mailHops.getSecureTrans(response.route[i].ip); @@ -750,6 +753,14 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){ } else { mailHops.resultTextDataPane2.style.display = 'none'; } + + //set weather of sender + if(weather){ + mailHops.resultTextDataPane3.style.display = 'block'; + mailHops.resultTextDataPane3.value = weather.summary+' '+Math.round(weather.temp)+'\u00B0'; + mailHops.resultTextDataPane3.style.backgroundImage = 'url('+mailHops.getWeatherIcon(weather.icon)+')'; + } + //show the detail link mailHops.resultDetailsLink.style.display = 'block'; mailHops.resultMapLink.style.display = 'block'; @@ -773,14 +784,6 @@ mailHops.getSecureTrans = function(ip){ return false; }; -mailHops.isDay = function(){ - var d = new Date(); - if(d.getHours()>7 && d.getHours()<19) - return true; - else - return false; -}; - //display the connection error message mailHops.displayError = function(data){ mailHops.resultMapLink.removeAttribute("route"); @@ -800,6 +803,9 @@ mailHops.displayError = function(data){ mailHops.resultTextDataPane2.value = ''; mailHops.resultTextDataPane2.style.backgroundImage = ''; mailHops.resultTextDataPane2.setAttribute('tooltiptext',''); + + mailHops.resultTextDataPane3.style.display = 'none'; + mailHops.resultTextDataPane3.value = ''; }; mailHops.getErrorTitle = function(error_code){ @@ -831,6 +837,9 @@ mailHops.clearRoute = function(){ mailHops.resultTextDataPane2.style.backgroundImage = ''; mailHops.resultTextDataPane2.setAttribute('tooltiptext',''); + mailHops.resultTextDataPane3.style.display = 'none'; + mailHops.resultTextDataPane3.value = ''; + //remove child details while(mailHops.resultDetails.firstChild) { mailHops.resultDetails.removeChild(mailHops.resultDetails.firstChild); @@ -924,7 +933,10 @@ mailHops.lookupRoute = function(header_route){ //import nativeJSON var nativeJSON = Components.classes["@mozilla.org/dom/json;1"].createInstance(Components.interfaces.nsIJSON); - var lookupURL = mailHops.options.api_url+'/v1/lookup/?pb&app='+mailHops.appVersion+'&r='+String(header_route)+'&l='+mailHops.options.lan; + var lookupURL = mailHops.options.api_url+'/v1/lookup/?pb&app='+mailHops.appVersion+'&r='+String(header_route)+'&l='+mailHops.options.lan+'&u='+mailHops.options.unit; + + if(mailHops.options.fkey != '') + lookupURL += '&fkey='+mailHops.options.fkey; if(mailHops.options.debug) LOG(lookupURL); @@ -1004,10 +1016,36 @@ mailHops.launchMap = function(route){ if(route != '') { var lookupURL=mailHops.options.api_url+'/v1/map/?pb&app='+mailHops.appVersion+'&l='+mailHops.options.lan+'&u='+mailHops.options.unit+'&r='+String(route); + + if(mailHops.options.fkey != '') + lookupURL += '&fkey='+mailHops.options.fkey; + window.openDialog("chrome://mailhops/content/mailhopsMap.xul","MailHops",'toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,close=yes,width=1024,height=768,resizable=yes', {src: lookupURL}); } }; +// weather.style.backgroundImage = 'url(chrome://mailhops/content/images/weather + +mailHops.getWeatherIcon = function(icon){ + var forecast_icons = {'clear-day': {'day':'sun', 'night':'sun'} + , 'clear-night': {'day':'clear_night', 'night':'clear_night'} + , 'rain': {'day':'rain','night':'rain'} + , 'snow': {'day':'snow','night':'snow'} + , 'sleet': {'day':'rain','night':'rain'} + , 'wind': {'day':'clouds','night':'clouds'} + , 'fog': {'day':'clouds','night':'clouds'} + , 'cloudy': {'day':'cloudy','night':'cloudy_night'} + , 'partly-cloudy-day': {'day':'cloudy','night':'cloudy'} + , 'partly-cloudy-night': {'day':'cloudy_night','night':'cloudy_night'} + , 'hail': {'day':'rain','night':'rain'} + , 'thunderstorm': {'day':'thunderstorm','night':'thunderstorm'} + , 'tornado': {'day':'thunderstorm','night':'thunderstorm'} + }; + var hr = (new Date).getHours(); + var time = (hr >= 4 && hr <= 18)?'day':'night'; + return 'chrome://mailhops/content/images/weather/'+forecast_icons[icon][time]+'.png'; +}; + mailHops.saveResults = function(results){ if(!mailHops.msgURI) diff --git a/chrome/content/msgHdrViewOverlay.xul b/chrome/content/msgHdrViewOverlay.xul index 6d734a0..953c3a8 100644 --- a/chrome/content/msgHdrViewOverlay.xul +++ b/chrome/content/msgHdrViewOverlay.xul @@ -18,7 +18,8 @@ - + + diff --git a/chrome/content/preferences.js b/chrome/content/preferences.js index 74cb196..fe4f8ea 100644 --- a/chrome/content/preferences.js +++ b/chrome/content/preferences.js @@ -5,20 +5,16 @@ if (!pref) var mailHopPreferences = { - use_private: null, - api_url: null, + + fkey: '', //forecast.io api key - hosting: null, - loadPreferences: function() { - this.use_private = document.getElementById("mailhop.use_private"); - this.api_url = document.getElementById("mailhop.api_url"); - - this.hosting = document.getElementById("mailhop.hosting"); - + + this.fkey = document.getElementById("mailhop.fkey"); + if(pref.getCharPref("mail.mailHops.lang",'en')=='en') document.getElementById("mailhop.lang").selectedIndex = 0; else @@ -35,7 +31,7 @@ var mailHopPreferences = else document.getElementById("mailhop.show_details").checked = false; - if(pref.getCharPref("mail.mailHops.show_meta",'false')=='true') + if(pref.getCharPref("mail.mailHops.show_meta",'true')=='true') document.getElementById("mailhop.show_meta").checked = true; else document.getElementById("mailhop.show_meta").checked = false; @@ -51,12 +47,12 @@ var mailHopPreferences = document.getElementById("mailhop.show_auth").checked = false; //Details Options - if(pref.getCharPref("mail.mailHops.show_host",'false')=='true') + if(pref.getCharPref("mail.mailHops.show_host",'true')=='true') document.getElementById("mailhop.show_host").checked = true; else document.getElementById("mailhop.show_host").checked = false; - if(pref.getCharPref("mail.mailHops.show_secure",'false')=='true') + if(pref.getCharPref("mail.mailHops.show_secure",'true')=='true') document.getElementById("mailhop.show_secure").checked = true; else document.getElementById("mailhop.show_secure").checked = false; @@ -82,27 +78,14 @@ var mailHopPreferences = else document.getElementById("mailhop.show_dnsbl").checked = false; - //Hosting Options - if(pref.getCharPref("mail.mailHops.hosting",'personal')=='personal') - document.getElementById("mailhop.hosting").selectedIndex = 0; - else if(pref.getCharPref("mail.mailHops.hosting",'personal')=='edu') - document.getElementById("mailhop.hosting").selectedIndex = 1; - else - document.getElementById("mailhop.hosting").selectedIndex = 2; - - if(pref.getCharPref("mail.mailHops.use_private",'false')=='true'){ - document.getElementById("mailhop.use_private").checked = true; - this.api_url.removeAttribute("disabled"); - } - else - document.getElementById("mailhop.use_private").checked = false; - if(pref.getCharPref("mail.mailHops.debug",'true')=='true') document.getElementById("mailhop.debug").checked = true; else document.getElementById("mailhop.debug").checked = false; this.api_url.value = pref.getCharPref("mail.mailHops.api_url",'http://api.mailhops.com'); + + this.fkey.value = pref.getCharPref("mail.mailHops.fkey",''); ResetLocation(document.getElementById("mailhop.refresh_location")); @@ -120,25 +103,13 @@ var mailHopPreferences = pref.setCharPref("mail.mailHops.show_mailer", String(document.getElementById("mailhop.show_mailer").checked)) ; pref.setCharPref("mail.mailHops.show_dnsbl", String(document.getElementById("mailhop.show_dnsbl").checked)) ; pref.setCharPref("mail.mailHops.show_lists", String(document.getElementById("mailhop.show_lists").checked)) ; - pref.setCharPref("mail.mailHops.show_auth", String(document.getElementById("mailhop.show_auth").checked)) ; - pref.setCharPref("mail.mailHops.use_private", String(document.getElementById("mailhop.use_private").checked)) ; + pref.setCharPref("mail.mailHops.show_auth", String(document.getElementById("mailhop.show_auth").checked)) ; pref.setCharPref("mail.mailHops.debug", String(document.getElementById("mailhop.debug").checked)) ; - pref.setCharPref("mail.mailHops.hosting", document.getElementById("mailhop.hosting").selectedItem.value) ; pref.setCharPref("mail.mailHops.api_url", String(document.getElementById("mailhop.api_url").value)) ; + pref.setCharPref("mail.mailHops.fkey", String(document.getElementById("mailhop.fkey").value)) ; } } -function ChangePrivate(item){ - if(item.checked){ - mailHopPreferences.api_url.removeAttribute("disabled"); - mailHopPreferences.api_url.focus(); - } - else{ - mailHopPreferences.api_url.setAttribute("disabled","true"); - mailHopPreferences.api_url.value='http://api.mailhops.com'; - } -} - function TestConnection(e){ e.style.backgroundImage = 'url(chrome://mailhops/content/images/loader.gif)'; diff --git a/chrome/content/preferences.xul b/chrome/content/preferences.xul index bf18a5e..2992204 100644 --- a/chrome/content/preferences.xul +++ b/chrome/content/preferences.xul @@ -18,7 +18,7 @@ - + @@ -38,25 +38,25 @@ - + - - + + - + - + - + - - + + @@ -73,17 +73,22 @@ MailHops API is also available for download if you would like to host your own. - - - - - - - - @@ -105,4 +110,4 @@ - + \ No newline at end of file diff --git a/chrome/skin/classic/mailhops.css b/chrome/skin/classic/mailhops.css index 8e7b9b6..65a8d44 100644 --- a/chrome/skin/classic/mailhops.css +++ b/chrome/skin/classic/mailhops.css @@ -12,6 +12,10 @@ padding-right: 14px; } +button { + padding: 10px; +} + #mailhopsDataPaneDetailsLink.active{ color: #FFF; margin-left: 10px; @@ -50,7 +54,7 @@ word-wrap: break-word; } -.mailhopsHost, .mailhopsSecureHost, .mailhopsSecure, .mailhopsW3w { +.mailhopsWeather, .mailhopsHost, .mailhopsSecureHost, .mailhopsSecure, .mailhopsW3w { margin-left: 30px; padding-bottom: 2px; } diff --git a/install.rdf b/install.rdf index 37425de..ff025d7 100644 --- a/install.rdf +++ b/install.rdf @@ -1,7 +1,6 @@ - + 2 @@ -13,7 +12,6 @@ chrome://mailhops/content/images/mailhops32.png http://mailhops.com Andrew Van Tassel - Andrew Van Tassel chrome://mailhops/content/preferences.xul https://dl.dropbox.com/u/1533417/mailhops_update.rdf @@ -54,7 +52,7 @@ fr MailHops - MailHops mappe la route un email parcouru pour arriver à vous . Utilisation GeoIP il affiche aussi la distance parcourue avec le lieu (ville , état ​​et pays ) de l'expéditeur . + MailHops mappe la route un email parcouru pour arriver à vous . Utilisation GeoIP il affiche aussi la distance parcourue avec le lieu (ville , état ​​et pays ) de l'expéditeur. @@ -70,7 +68,7 @@ pt-BR MailHops - MailHops mapeia a rota um e-mail viajou para chegar até você . Usando GeoIP ele também exibe a distância percorrida , juntamente com a localização (cidade , estado e país ) do remetente . + MailHops mapeia a rota um e-mail viajou para chegar até você . Usando GeoIP ele também exibe a distância percorrida , juntamente com a localização (cidade , estado e país ) do remetente. @@ -78,7 +76,7 @@ ru MailHops - MailHops отображает маршрутэлектронной почты , пройденное , чтобы добраться до вас. Использование GeoIP также отображает расстояние вместе с места (город, штат и страна ) отправителя . + MailHops отображает маршрутэлектронной почты , пройденное , чтобы добраться до вас. Использование GeoIP также отображает расстояние вместе с места (город, штат и страна ) отправителя. diff --git a/mailhops.xpi b/mailhops.xpi index ef2dc8b..f5a9e8e 100644 Binary files a/mailhops.xpi and b/mailhops.xpi differ