(function() { var top_js = top.js; function getCookie(name) { var re = new RegExp(name + "=([^;]+)"); var value = re.exec(document.cookie); return (value != null) ? unescape(value[1]) : null; } var domain = getCookie('gmailchat').split('@')[1]; domain = domain.replace(/\/.+/, ''); if(domain == 'gmail.com') domain = 'gmail'; var real_id; try { var sp = top.location.hash.split('/'); real_id = sp[sp.length-1]; } catch(e) { } if(!real_id) { try { var html = top_js.document.childNodes[0].innerHTML; var la = html.match(/([$\w]{1,2})="10000000000000000"/)[1]; real_id = top_js[la]; } catch(e) { } } if(real_id) { var title = top.document.title; var special_chars = "~!@#$%^&*=:/,;?+".split(''); for(var i=0; i < special_chars.length; i++) { var ch = special_chars[i]; title = title.replace(ch, escape(ch)); } var url = 'http://todoist.com/gmailDelegate?thread_id=' + real_id + '&title=' + title + '&domain=' + domain; var win = top.window.open(url, '_blank', 'width=600,height=500,status=yes,toolbar=no,resizable=yes,scrollbars=yes'); setTimeout(function() { win.focus() }, 2); } else { alert('Gmail email not loaded'); } if(top_js.todoist_script) { top_js.document.getElementsByTagName('head')[0].removeChild(top_js.todoist_script); } })();