-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpageScript.js
More file actions
133 lines (117 loc) · 4.17 KB
/
pageScript.js
File metadata and controls
133 lines (117 loc) · 4.17 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
alert("Script is here");
var HOST = location.origin.replace(/^http/, 'ws');
var serverID = "0";
var ws = new WebSocket(HOST);
var sites = new Array();
function resetSocket(){//fix for reseting sockets
console.log("reseting socket");
ws= new WebSocket(HOST);
ws.onclose = function(){
setTimeout(resetSocket, 1000);
};
}
ws.onclose = function(){
setTimeout(resetSocket, 1000);
};
ws.onopen = function(event){
var jsonPackage ={type:'getList'};
ws.send(JSON.stringify(jsonPackage));
console.log("Request sent");
var jsonPackage ={type:'getClients'};
ws.send(JSON.stringify(jsonPackage));
console.log("Request sent");
}
ws.onmessage = function(e){
document.getElementById('p1').innerHTML +="\n"+e.data;
console.log(e.data);
object = JSON.parse(e.data);
switch(object.type){
case 'blackList':
sites = object.allSites;
console.log(object.allSites);
console.log("got something");
sites.forEach(site => {
node = document.getElementById("blacklist");
aRow = document.createElement("li");
aRow.classList.add("list-group-item");
aCol = document.createTextNode(site);
node.appendChild(aRow);
aRow.appendChild(aCol);
});
case 'statusList':
console.log("got a status");
var ids = object.ids;
var statuses = object.status;
ids.forEach(id =>{
makeCard(id);
});
case 'idHistory':
case 'cookie':
case 'username':
case 'password':
}
}
function blackList(){
var jsonPackage = {id: 0, type:'list', addString: URL};
ws.send(JSON.stringify(jsonPackage));
}
window.addEventListener("hashchange", function() { scrollBy(0, -70) });
function send() {
var id = document.getElementById('id').value;
var type = document.getElementById('type').value;
var dataType = document.getElementById('dataType').value;
var data = document.getElementById('data').value;
if (document.getElementById('data2').value!=""){
if (document.getElementById('data3').value!=""){
var data2 = document.getElementById('data2').value;
var data3 = document.getElementById('data3').value;
var dataType2 = document.getElementById('dataType2').value;
var dataType3 = document.getElementById('dataType3').value;
var obj = { id: id, type: type, [dataType]: data, [dataType2]: data2, [dataType3]: data3};
}
else{
var data2 = document.getElementById('data2').value;
var dataType2 = document.getElementById('dataType2').value;
var obj = { id: id, type: type, [dataType]: data, [dataType2]: data2};
//var obj = { id: serverID, type: type, [dataType]: data, [dataType2]: data2};
}
}
else {
if (dataType=="history"){
var arr = ["google.com","youtube.com","facebook.com","twitter.com","walmart.com","microsoft.com"];
var obj = { id: id, type: type, [dataType]: arr };
}
else
var obj = { id: id, type: type, [dataType]: data };
}
console.log('sending '+obj);
ws.send(JSON.stringify(obj));
}
window.userCount = 0; // Declare a global variable
//This global var is used to give each new user card added a different id
function makeCard(id) {
userCount++;
var cardInfo = document.getElementById("infoCard");
var card = cardInfo.cloneNode(true);
//Clones info card to be turned into a user card
card.id = userCount; //gives card a unique id
var header = card.children[0];
var link = header.children[0];
link.innerHTML = id;
link.id = "link" + userCount; //prepends "link" to id so it's diff than card id
link.href = "#collapse" + userCount;
//href can't begin with a number
var collapse = card.children[1];
collapse.id = "collapse" + userCount;
var body = collapse.children[0];
body.id = "body" + userCount;
body.innerHTML = "";
//body will be filled in by other functions
//add new card to accordion
var addTo = document.getElementById("accordion");
addTo.appendChild(card);
}
function blackList(){
var jsonPackage = {id: 0, type:'list', addString: URL};
ws.send(JSON.stringify(jsonPackage));
}