()
| 48 | } |
| 49 | |
| 50 | getUserInfo() { |
| 51 | if (this.userInfo) { |
| 52 | return this.userInfo; |
| 53 | } |
| 54 | const titleElem = document.querySelector('title'); |
| 55 | // Gmail titles place the active account address last, e.g. |
| 56 | // "Inbox (5) - alice@example.com - Gmail". Take the last match so |
| 57 | // subject-line addresses don't shadow the account address. |
| 58 | const email = extractAddressFromText(titleElem.innerText, {position: 'last'}); |
| 59 | if (!email) { |
| 60 | throw new Error('Gmail User Id not found.'); |
| 61 | } |
| 62 | this.userInfo = {}; |
| 63 | this.userInfo.email = email; |
| 64 | this.userInfo.legacyGsuite = Array.from(document.querySelectorAll('.aiG .aiD span')).some(element => /^1(?:5|7)[\sG]/.test(element.textContent)); |
| 65 | return this.userInfo; |
| 66 | } |
| 67 | |
| 68 | getMsgId(msgElem) { |
| 69 | const rawID = msgElem.dataset.messageId; |
no test coverage detected