-
Notifications
You must be signed in to change notification settings - Fork 10
/
background.js
39 lines (33 loc) · 1.15 KB
/
background.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
console.log("UbiChr v"+CmdUtils.VERSION+" background script says hello");
// setup selection event sink
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (CmdUtils.DEBUG) {
console.log("got message: ", request.message, request.data, request.event );
//CmdUtils.notify(request.data, request.message+" / "+request.event );
}
switch(request.message)
{
case 'selection':
CmdUtils.selectedText = request.data || "";
break;
default:
sendResponse({data: 'Invalid arguments'});
break;
}
return true;
});
chrome.tabs.onUpdated.addListener( function(tabId, changeInfo, tab) {
if (CmdUtils.DEBUG) if (tab) console.log("onUpdated", tab.url);
CmdUtils.updateActiveTab();
return true;
})
chrome.tabs.onActivated.addListener(function(actInfo) {
if (CmdUtils.DEBUG) console.log("onActivated", actInfo);
CmdUtils.updateActiveTab();
return true;
});
chrome.tabs.onHighlighted.addListener( function(higInfo) {
if (CmdUtils.DEBUG) console.log("onHighlighted", higInfo);
CmdUtils.updateActiveTab();
return true;
})