-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
46 lines (27 loc) · 1.16 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
39
40
41
42
43
44
45
46
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-61616161']);
_gaq.push(['_trackPageview']);
function onClickHandler(info, tab) {
let urls = { url:'https://launchpad.support.sap.com/#/solutions/notesv2/?q=' + info.selectionText +'&sortBy=score&sortOrder=desc', no:info.selectionText};
chrome.tabs.create({ url: urls.url });
};
chrome.commands.onCommand.addListener(function(command) {
chrome.storage.local.get("definedURL", function(result){
if(result.definedURL!=undefined){
chrome.tabs.update({url:'http://'+result.definedURL});
_gaq.push(['_trackEvent', 'refresh', result.definedURL]);
}e
});
});
chrome.contextMenus.onClicked.addListener(onClickHandler);
// Set up context menu tree at install time.
chrome.runtime.onInstalled.addListener(function() {
// Create one test item for each context type.
var contexts = ["selection"];
for (var i = 0; i < contexts.length; i++) {
var context = contexts[i];
var title = "Search '" + context + "' in SAP Notes";
var id = chrome.contextMenus.create({"title": title, "contexts":[context],
"id": "context" + context});
}
});