Added generate password option to context menu
This commit is contained in:
parent
691d2625d7
commit
e671f35193
|
@ -13,6 +13,10 @@ var appIdService = new AppIdService();
|
|||
|
||||
chrome.commands.onCommand.addListener(function (command) {
|
||||
if (command === 'generate_password') {
|
||||
ga('send', {
|
||||
hitType: 'event',
|
||||
eventAction: 'Generated Password From Command'
|
||||
});
|
||||
passwordGenerationService.getOptions().then(function (options) {
|
||||
var password = passwordGenerationService.generatePassword(options);
|
||||
copyToClipboard(password);
|
||||
|
@ -88,6 +92,17 @@ function buildContextMenu() {
|
|||
contexts: ['all'],
|
||||
title: 'Copy Password'
|
||||
});
|
||||
|
||||
chrome.contextMenus.create({
|
||||
type: 'separator'
|
||||
});
|
||||
|
||||
chrome.contextMenus.create({
|
||||
type: 'normal',
|
||||
id: 'generate-password',
|
||||
contexts: ['all'],
|
||||
title: 'Generate Password (copied)'
|
||||
});
|
||||
}
|
||||
|
||||
chrome.tabs.onActivated.addListener(function (activeInfo) {
|
||||
|
@ -175,7 +190,17 @@ function loadMenuAndUpdateBadge(url, tabId, loadContextMenuOptions) {
|
|||
}
|
||||
|
||||
chrome.contextMenus.onClicked.addListener(function (info, tab) {
|
||||
if (info.parentMenuItemId === 'autofill' || info.parentMenuItemId === 'copy-username' ||
|
||||
if (info.menuItemId === 'generate-password') {
|
||||
ga('send', {
|
||||
hitType: 'event',
|
||||
eventAction: 'Generated Password From Context Menu'
|
||||
});
|
||||
passwordGenerationService.getOptions().then(function (options) {
|
||||
var password = passwordGenerationService.generatePassword(options);
|
||||
copyToClipboard(password);
|
||||
});
|
||||
}
|
||||
else if (info.parentMenuItemId === 'autofill' || info.parentMenuItemId === 'copy-username' ||
|
||||
info.parentMenuItemId === 'copy-password') {
|
||||
var id = info.menuItemId.split('_')[1];
|
||||
if (id === 'noop') {
|
||||
|
|
Loading…
Reference in New Issue