|
| 1 | +/* |
1 | 2 | function attachLinks(messageView) {
|
2 | 3 | var url = 'https://mail.google.com/mail/#all/' + messageView.getMessageID();
|
3 | 4 | // TODO: or https://mail.google.com/mail/h/ouilk5cfmn2l/?th=MESSAGE_ID&v=c ?
|
4 | 5 | var threadView = messageView.getThreadView();
|
5 |
| - var div = document.createElement('div'); |
6 |
| - var link = document.createElement('a'); |
7 |
| - link.href = url; |
8 |
| - link.target = '_blank'; |
9 |
| - link.innerHTML = 'Permalink to this email'; |
10 |
| - div.style = 'text-align: center;'; |
11 |
| - div.appendChild(link); |
12 |
| - var res = threadView.addSidebarContentPanel({ |
13 |
| - el: div, |
14 |
| - title: 'Permalink: ' + threadView.getSubject(), |
15 |
| - iconUrl: chrome.extension.getURL('link.png'), |
| 6 | + attachThreadLink(threadView); |
| 7 | +} |
| 8 | +*/ |
| 9 | +function attachThreadLink(threadView) { |
| 10 | + threadView.getThreadIDAsync().then(function(threadId) { |
| 11 | + console.log('[google-inbox-permalinks] getThreadIDAsync => ', arguments); |
| 12 | + if (!threadId) return; |
| 13 | + var link = document.createElement('a'); |
| 14 | + link.href = 'https://mail.google.com/mail/#all/' + threadId; |
| 15 | + link.target = '_blank'; |
| 16 | + link.appendChild(document.createTextNode('Permalink')); |
| 17 | + // note: threadView.getSubject() contains junk in the French version of Google Inbox |
| 18 | + var div = document.createElement('div'); |
| 19 | + //div.style = 'text-align: center;'; |
| 20 | + div.appendChild(link); |
| 21 | + threadView.addSidebarContentPanel({ |
| 22 | + el: div, |
| 23 | + title: 'Permalinks', |
| 24 | + iconUrl: chrome.extension.getURL('link.png'), |
| 25 | + }); |
| 26 | + }).catch(function() { |
| 27 | + console.log('[google-inbox-permalinks] getThreadIDAsync => error:', arguments); |
16 | 28 | });
|
17 | 29 | }
|
18 | 30 |
|
19 | 31 | InboxSDK.load('2', 'sdk_inbox-permalink_77495e9cd5').then(function(sdk){
|
20 |
| - sdk.Conversations.registerMessageViewHandler(attachLinks); |
| 32 | + //sdk.Conversations.registerMessageViewHandler(attachLinks); |
| 33 | + sdk.Conversations.registerThreadViewHandler(attachThreadLink); |
21 | 34 | });
|
0 commit comments