forked from bmoreinis/fakenews
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
executable file
·37 lines (35 loc) · 1.31 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
/* Fake News Fitness Pseudocode
* https://drive.google.com/open?id=0B54VzDPRtma7dG5mUlBhNW1zX2c
*/
/*
* load popup to inform user and offer option button (free / prefill)
* listen for checkpage button and call CONTROLLER module
*/
document.addEventListener('DOMContentLoaded', function() {
var checkPageButton = document.getElementById('checkPage');
checkPageButton.addEventListener('click', function() {
chrome.tabs.query({active : true}, function(tab) {
//Check if user wants form pre-filled
var checkBox = document.getElementById('fillForm');
if (checkBox.checked) {
var req = new XMLHttpRequest();
function sendFilled() {
var whois = req.responseText;
console.log(whois);
chrome.tabs.sendMessage(tab[0].id, {text:'build_form_filled', whois: whois}, null);
};
var url = new URL(tab[0].url);
var domain = url.hostname;
console.log(tab[0].url);
req.open("GET","http://api.bulkwhoisapi.com/whoisAPI.php?domain="+domain+"&token=usemeforfree");
req.onload = sendFilled;
req.send(null);
}
else {
//Display blank form
chrome.tabs.sendMessage(tab[0].id, {text: 'build_form_blank'}, null);
};
//}, false);
});
}, false);
}, false);