diff --git a/chrome.manifest b/chrome.manifest index 55b1d3a..050468c 100644 --- a/chrome.manifest +++ b/chrome.manifest @@ -10,7 +10,9 @@ locale mailhops ru jar:chrome/mailhops.jar!/locale/ru/ locale mailhops zh-CN jar:chrome/mailhops.jar!/locale/zh-CN/ # Postbox -overlay chrome://messenger/content/msgHdrViewOverlay.xul chrome://mailhops/content/pb-overlay.xul application=postbox@postbox-inc.com +# overlay chrome://messenger/content/msgHdrViewOverlay.xul chrome://mailhops/content/pb-overlay.xul application=postbox@postbox-inc.com +overlay chrome://messenger/content/mailWindowOverlay.xul chrome://mailhops/content/msgNotificationBar.xul application=postbox@postbox-inc.com # Thunberbird -overlay chrome://messenger/content/msgHdrViewOverlay.xul chrome://mailhops/content/tb-overlay.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6} \ No newline at end of file +# overlay chrome://messenger/content/msgHdrViewOverlay.xul chrome://mailhops/content/tb-overlay.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6} +overlay chrome://messenger/content/mailWindowOverlay.xul chrome://mailhops/content/msgNotificationBar.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6} diff --git a/chrome/content/images/btn-add-to-slack-122x35.png b/chrome/content/images/btn-add-to-slack-122x35.png new file mode 100644 index 0000000..f2661ae Binary files /dev/null and b/chrome/content/images/btn-add-to-slack-122x35.png differ diff --git a/chrome/content/images/refresh.png b/chrome/content/images/refresh.png new file mode 100644 index 0000000..ac99923 Binary files /dev/null and b/chrome/content/images/refresh.png differ diff --git a/chrome/content/mailhops.js b/chrome/content/mailhops.js index 22c3615..22b04e8 100644 --- a/chrome/content/mailhops.js +++ b/chrome/content/mailhops.js @@ -39,7 +39,7 @@ mailHops.init = function() { //load preferences mailHops.loadPref(); - document.getElementById("mailhopsDataPanePrefsLink").addEventListener("click", function () { + document.getElementById("mailhopsLogo").addEventListener("click", function () { window.openDialog("chrome://mailhops/content/preferences.xul","","chrome, dialog, modal, centerscreen").focus(); }); @@ -63,7 +63,6 @@ mailHops.loadPref = function() mailHops.options.show_details = mailHops.getCharPref('mail.mailHops.show_details','true')=='true'?true:false; mailHops.options.show_meta = mailHops.getCharPref('mail.mailHops.show_meta','true')=='true'?true:false; mailHops.options.show_auth = mailHops.getCharPref('mail.mailHops.show_auth','true')=='true'?true:false; - mailHops.options.show_lists = mailHops.getCharPref('mail.mailHops.show_lists','true')=='true'?true:false; //Details options mailHops.options.show_host = mailHops.getCharPref('mail.mailHops.show_host','true')=='true'?true:false; @@ -174,8 +173,7 @@ mailHops.getRoute = function(){ var headXMimeOLE = (mailHops.options.show_auth && mailHops.options.show_mailer) ? mailHops.headers.extractHeader ( "X-MimeOLE" , false ) : null; var headReceivedSPF = (mailHops.options.show_auth && mailHops.options.show_spf) ? mailHops.headers.extractHeader ( "Received-SPF" , false ) : null; var headAuth = mailHops.options.show_auth ? mailHops.headers.extractHeader ( "Authentication-Results" , false ) : null; - //lists box - var headListUnsubscribe = mailHops.options.show_lists ? mailHops.headers.extractHeader ( "List-Unsubscribe" , false ) : null; + var headListUnsubscribe = mailHops.headers.extractHeader ( "List-Unsubscribe" , false ) ; var all_ips = new Array(); var rline = '',firstDate=headDate,lastDate; @@ -183,9 +181,7 @@ mailHops.getRoute = function(){ mailHops.message.secure = []; mailHops.message.time = null; - if(mailHops.options.show_lists){ - mailHopsDisplay.lists( headListUnsubscribe ); - } + mailHopsDisplay.lists( headListUnsubscribe ); if(mailHops.options.show_auth){ mailHopsDisplay.auth( headXMailer, headUserAgent, headXMimeOLE, headAuth, headReceivedSPF ); diff --git a/chrome/content/msgNotificationBar.js b/chrome/content/msgNotificationBar.js new file mode 100644 index 0000000..c59f3e5 --- /dev/null +++ b/chrome/content/msgNotificationBar.js @@ -0,0 +1,348 @@ +var mailHopsDisplay = +{ + resultBox: null, + resultText: null, + resultDetails: null, + container: null, + mailhopsDataPaneSPF: null, + mailhopsDataPaneDKIM: null, + mailhopsDataPaneMailer: null, + mailhopsDataPaneDNSBL: null, + mailhopsResultWeather: null, + mailhopsUnsubscribe: null, + options: null, + + init: function(options){ + + this.options = options; + + this.container = document.getElementById("mailhopsBox"); + this.resultBox = document.getElementById("mailhopsResult"); + this.resultText = document.getElementById("mailhopsResultText"); + this.mailhopsResultWeather = document.getElementById("mailhopsResultWeather"); + this.resultDetails = document.getElementById("mailhopsDataPaneDetails"); + //auth + this.mailhopsDataPaneSPF = document.getElementById("mailhopsDataPaneSPF"); + this.mailhopsDataPaneDKIM = document.getElementById("mailhopsDataPaneDKIM"); + this.mailhopsDataPaneMailer = document.getElementById("mailhopsDataPaneMailer"); + this.mailhopsDataPaneDNSBL = document.getElementById("mailhopsDataPaneDNSBL"); + + this.mailhopsUnsubscribe = document.getElementById("mailhopsUnsubscribe"); + + //event listner for route click to launch map + this.mailhopsDataPaneDNSBL.addEventListener("click", function () { + if(this.hasAttribute('data-ip')) + mailHopsUtils.launchSpamHausURL( this.getAttribute('data-ip') ); + }); + + this.resultText.addEventListener("click", function () { + if(this.value.indexOf('Rate Limit')!==-1){ + window.openDialog("chrome://mailhops/content/preferences.xul","","chrome, dialog, modal, centerscreen").focus(); + } + else if(this.hasAttribute('data-route')) + mailHopsUtils.launchMap( String(this.getAttribute('data-route')), options ); + }); + }, + + lists: function( header_unsubscribe ){ + + this.mailhopsUnsubscribe.style.display='none'; + + if(header_unsubscribe){ + this.mailhopsUnsubscribe.style.display=''; + var listArr=header_unsubscribe.split(','); + var href=''; + if(listArr.length){ + for(var h=0;h',''); + if(href.indexOf('mailto:')!=-1){ + if(href.toLowerCase().indexOf('subject=')==-1){ + if(href.indexOf('?')==-1) + href+='?subject=Unsubscribe'; + else + href+='&subject=Unsubscribe'; + } + } + this.mailhopsUnsubscribe.setAttribute('href',href); + } + } + } + }, + + auth: function( header_xmailer, header_useragent, header_xmimeole, header_auth, header_spf ){ + //SPF + if(header_spf){ + header_spf=header_spf.replace(/^\s+/,""); + var headerSPFArr=header_spf.split(' '); + this.mailhopsDataPaneSPF.setAttribute('value','SPF: '+headerSPFArr[0]); + this.mailhopsDataPaneSPF.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/'+headerSPFArr[0]+'.png)'; + this.mailhopsDataPaneSPF.setAttribute('tooltiptext',header_spf+'\n'+mailHopsUtils.spf(headerSPFArr[0])); + this.mailhopsDataPaneSPF.style.display='block'; + } else { + this.mailhopsDataPaneSPF.style.display='none'; + } + //Authentication-Results + //http://tools.ietf.org/html/rfc5451 + if(header_auth){ + var headerAuthArr=header_auth.split(';'); + var dkim_result; + var spf_result; + for(var h=0;h 0) + distanceText = mailHopsUtils.addCommas(Math.round(response.distance.kilometers))+' km traveled'; + else if(response.distance.miles > 0) + distanceText = mailHopsUtils.addCommas(Math.round(response.distance.miles))+' mi traveled'; + } else if(displayText=='') + displayText = ' Local message.'; + } + + if(message.time != null){ + message.time = message.time/1000; + if(message.time < 60) + distanceText += ' in '+message.time+' sec.'; + else if(message.time < 3600) //something is wrong if it takes this long + distanceText += ' in '+Math.round(message.time/60)+' min.'; + else //something is wrong if it takes this long + distanceText += ' in '+Math.round(message.time/60/60)+' hr.'; + } + + if(header_route) + this.resultText.setAttribute("data-route", header_route); + else + this.resultText.removeAttribute("data-route"); + + this.resultText.setAttribute('value', displayText+' ( '+distanceText+' )'); + this.resultText.style.backgroundImage = 'url('+image+')'; + }//end route +}; diff --git a/chrome/content/msgNotificationBar.xul b/chrome/content/msgNotificationBar.xul new file mode 100644 index 0000000..a5f8bb8 --- /dev/null +++ b/chrome/content/msgNotificationBar.xul @@ -0,0 +1,45 @@ + + + + + + + +