-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
27 lines (23 loc) · 873 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
chrome.commands.onCommand.addListener(function (command) {
window.mynamespace = window.mynamespace || {};
if(command === "generate"){
chrome.tabs.query({currentWindow: true, active: true},
function (tab) {
chrome.tabs.sendMessage(tab[0].id, mynamespace.generateUuid());
})
}
else if(command === "copyGuid"){
var textArea = document.createElement("textarea");
textArea.value = mynamespace.generateUuid();
textArea.style.position="fixed"; //avoid scrolling to bottom
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
} catch (err) {
console.log('Unable to copy guid');
}
document.body.removeChild(textArea);
}
})