-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbackground-ui.js
45 lines (41 loc) · 1.03 KB
/
background-ui.js
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
/*
korporize for korpora (Apache 2.0) by https://github.com/gnonio
Copyright 2020 Pedro SOARES
*/
browser.contextMenus.create({
id: "extractTextLoadedImage",
title: "Extract Text from Image",
contexts: ["image"]
})
/*browser.contextMenus.create({
id: "extractTextLink",
title: "Extract Text from Link",
contexts: ["link"]
})
browser.contextMenus.create({
id: "extractTextPage",
title: "Extract Text from Page",
contexts: ["page"]
})*/
async function handleUI(info, tab) {
await conditionalCPInject( tab.id )
switch ( info.menuItemId ) {
/*
CONTENT PAGE COMMUNICATION
*/
case "extractTextLoadedImage":
browser.tabs.sendMessage( tab.id, {
method: "CP_extractTextLoadedImage", data: info.srcUrl} )
break
/*
OTHER COMMUNICATION
*/
/*case "extractTextLink":
console.log( "extractTextLink", info, tab )
break
case "extractTextPage":
console.log( "extractTextPage", info, tab )
break*/
}
}
browser.contextMenus.onClicked.addListener( handleUI )