-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
61 lines (54 loc) · 1.1 KB
/
background.js
File metadata and controls
61 lines (54 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function updateKey()
{
getID(getKey);
}
function getKeyForPlugin(id)
{
if ("" != id)
{
chrome.storage.sync.get(
{
passwords: null
},
function(items)
{
if (null != items.passwords[id])
{
encryptMessage(items.passwords[id]);
}
else
{
alert("Сначала введите ключ!");
}
});
}
}
function encryptMessage(key)
{
chrome.tabs.executeScript({
code: 'encryptMessage("' + key + '");'
});
}
chrome.commands.onCommand.addListener(function(command)
{
if ("encrypt" == command)
{
getID(getKeyForPlugin);
}
});
function getEncryptClickHandler() {
return function(info, tab) {
getID(getKeyForPlugin);
};
};
//контекстное меню для шифровки сообщения
chrome.contextMenus.create({
"title" : "Зашифровать",
"type" : "normal",
"contexts" : ["all"],
"onclick" : getEncryptClickHandler()
});
//todo обновлять ключ только при смене страницы/вкладки
chrome.tabs.onUpdated.addListener(function(tabID, changeInfo, tab){
updateKey();
});