-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheventpage.js
More file actions
27 lines (23 loc) · 836 Bytes
/
eventpage.js
File metadata and controls
27 lines (23 loc) · 836 Bytes
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
var menuItem = {
"id": "Search_me",
"title": "Search_me",
"contexts": ["selection"]
};
chrome.contextMenus.create(menuItem);
function fixedEncodeURI (str) {
return encodeURI(str).replace(/%5B/g, '[').replace(/%5D/g, ']');
}
chrome.contextMenus.onClicked.addListener(function(clickData){
if (clickData.menuItemId == "Search_me" && clickData.selectionText){
var Search_meUrl = "https://en.wikipedia.org/wiki/" + fixedEncodeURI(clickData.selectionText);
var createData = {
"url": Search_meUrl,
"type": "popup",
"top": 5,
"left": 5,
"width": screen.availWidth/2,
"height": screen.availHeight/2
};
chrome.windows.create(createData, function(){});
}
});