-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
31 lines (28 loc) · 1001 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
28
29
30
31
var tabURL;
// A function to use as callback
function doStuffWithDom(issueId) {
tabURL = tabURL + issueId;
// Create a dummy input to copy the string array inside it
var dummy = document.createElement("input");
// Add it to the document
document.body.appendChild(dummy);
// Set its ID
dummy.setAttribute("id", "dummy_id");
// Output the array into it
document.getElementById("dummy_id").value = tabURL;
// Select it
dummy.select();
// Copy its contents
document.execCommand("copy");
// Remove it as its not needed anymore
document.body.removeChild(dummy);
}
function genericOnClick(info, tab) {
tabURL = tab.url + "/#";
console.log(tabURL);
chrome.tabs.sendMessage(tab.id, {text: 'report_back'}, doStuffWithDom);
}
var context = "page";
var title = "Copy issue id URL to clipboard";
var id = chrome.contextMenus.create({"title": title, "contexts":[context],
"onclick": genericOnClick});