-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
27 lines (25 loc) · 927 Bytes
/
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
chrome.commands.onCommand.addListener(function(command) {
if (command == "toggle-copy") {
// Get the currently selected tab
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
// chrome.tabs.query invokes the callback with a list of tabs that match the
// query. When the popup is opened, there is certainly a window and at least
// one tab, so we can safely assume that |tabs| is a non-empty array.
// A window can only have one active tab at a time, so the array consists of
// exactly one tab.
var tab = tabs[0];
toggleCopy(tab);
});
}
});
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.action === 'copyurl') {
getFormat(function(format) {
var buf = parseText(format, request.linkdata);
copyToClipBoard(buf);
notify(buf);
});
}
});
updateContextMenu();