зеркало из https://github.com/mozilla/email-tabs.git
Fix #22, add a context menu
This commit is contained in:
Родитель
0b5a88fca3
Коммит
14e22698cb
|
@ -57,6 +57,43 @@ sendEvent({
|
|||
ni: true,
|
||||
});
|
||||
|
||||
browser.contextMenus.create({
|
||||
id: "email-tab",
|
||||
title: "Email Tab",
|
||||
contexts: ["page", "tab"],
|
||||
documentUrlPatterns: ["<all_urls>"],
|
||||
});
|
||||
|
||||
browser.contextMenus.onClicked.addListener(async (info, tab) => {
|
||||
let mailProvider = (await browser.storage.local.get("mailProvider")).mailProvider;
|
||||
if (!mailProvider) {
|
||||
browser.notifications.create("error-no-preference", {
|
||||
type: "basic",
|
||||
title: "Email Tabs",
|
||||
message: "You must first set your mail provider using the toolbar button",
|
||||
});
|
||||
sendEvent({
|
||||
ec: "interface",
|
||||
ea: "context-menu-failed-pref",
|
||||
ni: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
let customDimensions = {
|
||||
cd1: await browser.tabs.query({currentWindow: true}).length,
|
||||
cd2: 1,
|
||||
cd3: tab.active,
|
||||
cd6: false,
|
||||
cd7: mailProvider,
|
||||
};
|
||||
sendEvent(Object.assign({
|
||||
ec: "interface",
|
||||
ea: "context-menu",
|
||||
el: "email-tabs",
|
||||
}, customDimensions));
|
||||
sendEmail([tab.id], mailProvider, customDimensions);
|
||||
});
|
||||
|
||||
function pause(time) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, time);
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
"clipboardWrite",
|
||||
"notifications",
|
||||
"storage",
|
||||
"contextMenus",
|
||||
"<all_urls>"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -147,6 +147,27 @@ cd6,
|
|||
cd7
|
||||
```
|
||||
|
||||
###### When the user uses the context menu to email tabs
|
||||
|
||||
```
|
||||
ec: interface
|
||||
ea: context-menu,
|
||||
el: email-tabs,
|
||||
cd1,
|
||||
cd2,
|
||||
cd3,
|
||||
cd6,
|
||||
cd7
|
||||
```
|
||||
|
||||
####### If the context menu failed because no mail provider was selected
|
||||
|
||||
```
|
||||
ec: interface,
|
||||
ea: context-menu-failed-pref,
|
||||
ni: true
|
||||
```
|
||||
|
||||
###### When the user is not logged in, or encounters a compose window error
|
||||
`el` will be `account` if we believe the user encountered a login form, or `error` if there's some other problem encountered.
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче