mirror of
https://github.com/XFox111/PasswordGeneratorExtension.git
synced 2026-04-22 08:08:01 +03:00
Version 1.0 (initial commit)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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();
|
||||
});
|
||||
Reference in New Issue
Block a user