-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
executable file
·49 lines (32 loc) · 1.16 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
var executeParams = {};
var executeDetails = function(params) {
const CONFIG = {
JIRA_URL : "https://jira.app.gittigidiyor.net/",
ENDPOINT : {
ISSUES : "rest/greenhopper/1.0/xboard/work/allData.json"
}
};
var urlParams = new URLSearchParams(window.location.search);
var requestParams = '?rapidViewId={rapidView}'.replace('{rapidView}', urlParams.get('rapidView'));
var requestUrl = CONFIG.JIRA_URL + CONFIG.ENDPOINT.ISSUES + requestParams;
var xhr = new XMLHttpRequest();
xhr.open("GET", requestUrl, false);
xhr.onload = function() {
try {
var response = JSON.parse(xhr.responseText);
var issues = response.issuesData.issues;
chrome.storage.local.set({'issues': issues});
} catch(e) {
chrome.storage.local.set({'issues': []});
console.log(e);
}
}
xhr.send();
};
var executeCallback = function(response) {
// OPEN PRINT PAGE
chrome.tabs.create({url: chrome.extension.getURL('print/print.html')});
};
chrome.tabs.executeScript({
code: '(' + executeDetails + ')(' + JSON.stringify(executeParams) + ');'
}, executeCallback);