-
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) · 784 Bytes
/
sample.js
File metadata and controls
25 lines (20 loc) · 784 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
// The onClicked callback function.
function onClickHandler(info, tab) {
var text = encodeURIComponent(info.selectionText || tab.title);
var pageUrl = encodeURIComponent(info.pageUrl);
chrome.windows.create({
url: "https://twitter.com/intent/tweet?text=" + text + "&url=" + pageUrl,
type: "panel",
top: 0,
left: 0,
height: 400,
width: 700
});
}
chrome.contextMenus.onClicked.addListener(onClickHandler);
chrome.runtime.onInstalled.addListener(function () {
//Define right click context
var contexts = ["page", "selection", "link", "editable", "image", "video", "audio"];
//Add item to context menu
chrome.contextMenus.create({"title": "Tweet This!", "id": "select2Tweet", "contexts": contexts});
});