-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
64 lines (57 loc) · 1.15 KB
/
Copy pathbackground.js
File metadata and controls
64 lines (57 loc) · 1.15 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
61
62
63
64
var addSearchId = 1
var adjustImportId = 2
function addContextMenuItem()
{
chrome.contextMenus.create(
{
type:"normal",
id:"addSearch",
title:"Add search to Bubble Dictionary",
contexts:["editable"],
onclick:contextMenuClickHandler
})
chrome.contextMenus.create(
{
type:"normal",
id:"adjustImport",
title:"Adjust the imported content to this",
contexts:["selection"],
onclick:contextMenuClickHandler
})
for (sIndex in sites.idList)
{
var id = sites.idList[sIndex]
chrome.contextMenus.create(
{
type:"normal",
id:id,
title:"Adjust the imported content to the selected for "+sites[id].name,
parentId:"adjustImport",
contexts:["selection"],
onclick:contextMenuClickHandler
})
}
console.log("added context menu items")
}
function makeMessage(key, data)
{
return {key:key,data:data}
}
function contextMenuClickHandler(info, tab)
{
console.log("context menu clicked")
console.log(info)
console.log(tab)
chrome.tabs.sendMessage(tab.id, makeMessage("contextMenuItemClicked", {info:info}))
}
function run()
{
console.log("run")
if (!sitesReady)
{
setTimeout(run, 50)
return
}
addContextMenuItem()
}
run()