1
0
mirror of https://github.com/XFox111/PasswordGeneratorExtension.git synced 2026-04-22 08:08:01 +03:00
Files
PasswordGeneratorExtension/js/background.js
T
2020-10-06 16:27:04 +03:00

35 lines
763 B
JavaScript

function AddContextMenu()
{
chrome.contextMenus.create(
{
id: "generate",
contexts: [ "all" ],
title: chrome.i18n.getMessage("generate")
}
);
}
// Setting up context menu event listener
chrome.contextMenus.onClicked.addListener(() => GeneratePassword(null));
// Adding context menu entry if needed
chrome.runtime.onInstalled.addListener(() =>
{
// Adding context menu option
chrome.storage.sync.get({ showContext: true }, (settings) =>
{
if (settings.showContext !== false)
AddContextMenu();
});
});
chrome.storage.onChanged.addListener((changes, area) =>
{
if (area != "sync" || changes["showContext"] == null)
return;
if (changes["showContext"].newValue === false)
chrome.contextMenus.removeAll();
else
AddContextMenu();
});