-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.js
More file actions
25 lines (20 loc) · 911 Bytes
/
sample.js
File metadata and controls
25 lines (20 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The onClicked callback function.
function onClickHandler(info, tab) {
chrome.tabs.sendMessage(tab.id, {method: "getSelection"}, function(response){
sendServiceRequest(response.data);
});
};
function sendServiceRequest(selectedText){
var text = encodeURIComponent(selectedText);
var serviceCall = "http://nodictionaries.com/novifex?text=" + text;
chrome.tabs.create({url: serviceCall});
}
chrome.contextMenus.onClicked.addListener(onClickHandler);
// Set up context menu tree at install time.
chrome.runtime.onInstalled.addListener(function() {
var id = chrome.contextMenus.create({"title": "no dictionaries!", "contexts":["selection"],
"id": "selection"});
});