forked from bkonetzny/link-to-inbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
link-to-inbox.min.js
1 lines (1 loc) · 1.16 KB
/
link-to-inbox.min.js
1
!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof module&&module.exports?module.exports=t():e.linkToInbox=t()}(this,function(){var e=function(e,a,n,r){r=r||"Check your %s inbox";var c=o(e,a,n);if(!c)return!1;var s=t(e,a,n),i=r.replace(/%s/gi,c.name);return'<a href="'+s+'" target="_blank">'+i+"</a>"},t=function(e,t,a){var n=o(e,t,a);if(!n)return!1;var r=n.protocol+"://"+n.domain+n.path;return r},o=function(e,t,o){var a=!0,n=e.split("@")[1],r=null,c={name:n,protocol:"https",domain:n,path:""};switch(t&&(r={},t.subject&&(r.subject=encodeURIComponent(t.subject)),t.sender&&(r.sender=encodeURIComponent(t.sender))),n){case"gmail.com":case"googlemail.com":c.name="Gmail",c.domain="mail.google.com",c.path="/mail/u/0/",r&&(c.path+="#search/in%3Aanywhere",r.subject&&(c.path+="+subject%3A%22"+r.subject+"%22"),r.sender&&(c.path+="+from%3A"+r.sender));break;case"live.com":case"hotmail.com":case"outlook.com":c.name="Outlook",c.domain="mail.live.com",c.path="/",r&&(c.path+="?fid=flsearch&srch=1&sdr=4&satt=0",r.subject?c.path+="&skws="+r.subject:r.sender&&(c.path+="&skws="+r.sender));break;default:a=!1}return o&&!a?!1:c};return{createLink:e,getHref:t}});