-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
65 lines (54 loc) · 1.61 KB
/
script.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
function getselection(info, tab) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (xhttp.readyState == 4 && xhttp.status == 200) {
parseResults(xhttp);
}
};
xhttp.open("GET", "http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-ox/SNVA?" + info.selectionText, true);
xhttp.send();
}
function parseResults(xml) {
chrome.tabs.create({
url: chrome.extension.getURL('popup.html'),
active: false
}, function (tab) {
// After the tab has been created, open a window to inject the tab
chrome.windows.create({
tabId: tab.id,
type: 'popup',
focused: true
// incognito, top, left, ...
});
});
var xmlDoc = xml.responseXML;
var data = xmlDoc.getElementsByTagName("Sesame")[0].getElementsByTagName("Target")[0].getElementsByTagName("Resolver")[0];
var ra = data.getElementsByTagName("jradeg")[0].innerHTML;
alert(ra);
}
function loadData() {
chrome.tabs.executeScript({
code: "window.getSelection().toString();"
}, function (selection) {
getselection(selection[0], null);
});
}
function parseRaDec(coord) {
}
chrome.contextMenus.create({
title: "Details: %s",
contexts:["selection"],
onclick: getselection,
});
//window.addEventListener('load', function (evt) {
// //loadData();
//});;
//window.addEventListener('activate', function (evt) {
// // loadData();
//});;
chrome.browserAction.onClicked.addListener(function(tab) {
loadData();
});
window.onload = function () {
console.log("onload" + Date())
}