-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
70 lines (56 loc) · 2.2 KB
/
popup.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
let changeColor = document.getElementById("changeColor");
changeColor.addEventListener("click", async () => {
let inputtag = document.querySelector("#tagcolor");
chrome.storage.sync.set({ inputtag: inputtag.value });
let [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
chrome.scripting.executeScript({
target: { tabId: tab.id },
function: setBorderColor,
});
});
function setBorderColor() {
chrome.storage.sync.get("inputtag", ({ inputtag }) => {
//console.log(inputtag);
jSelector = document.querySelector('#summary-val')
if(typeof(jSelector) == 'undefined' || jSelector == null){
alert("Navigate to a specific jira");
return;
}
jUrl = window.location.href;
urlParts = jUrl.split("/");
jNumber = urlParts[urlParts.length - 1];
jTitle = document.querySelector('#summary-val').innerText;
jDescription = document.querySelector('.user-content-block').innerText;
if(inputtag == 'title'){
content = jNumber + ": " + jTitle;
//console.log(content);
navigator.clipboard.writeText(content);
alert("Copied to Clipboard");
}
if(inputtag == 'copydetails'){
content = "Jira: "+jNumber + "\n";
content = content + "Title: "+jTitle + "\n";
content = content + "Description: "+"\n\n"+jDescription + "\n\n";
content = content + "------------------------------------------------------------------";
content = content + "\n\n";
//console.log(content);
navigator.clipboard.writeText(content);
alert("Copied to Clipboard");
}
if(inputtag == 'savedetails'){
content = "Jira: "+jNumber + "\n";
content = content + "Title: "+jTitle + "\n";
content = content + "Description: "+"\n\n"+jDescription + "\n\n";
content = content + "------------------------------------------------------------------";
content = content + "\n\n";
//console.log(content);
filename = "Analysis_"+jNumber+".txt";
fileContent = content;
bb = new Blob([fileContent ], { type: 'text/plain' });
a = document.createElement('a');
a.download = filename;
a.href = window.URL.createObjectURL(bb);
a.click();
}
});
}