-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
83 lines (69 loc) · 2.26 KB
/
main.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
var i = 0;
function go() {
document.getElementById("psip").style.visibility = "hidden";
document.getElementById("psip").value = "localhost";
document.getElementById("cb").style.visibility = "hidden";
removeOptions(document.getElementById("cb"));
}
function addOption(selectbox,text,value )
{var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
function removeOptions(selectElement) {
var i, L = selectElement.options.length - 1;
for(i = L; i >= 0; i--) {
selectElement.remove(i);
}
}
var getPayload = function(payload, onLoadEndCallback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', payload);
xhr.send();
xhr.responseType = "arraybuffer";
xhr.onload = function (event) {
if (onLoadEndCallback) onLoadEndCallback(xhr, event);
};
}
var sendPayload = function(url, data, onLoadEndCallback) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.send(data);
xhr.onload = function (event) {
if (onLoadEndCallback) onLoadEndCallback(xhr, event);
};
}
function LoadviaGoldhen(PLfile){
var PS4IP = document.getElementById("psip").value;
var xhr = new XMLHttpRequest();
xhr.open("POST", `http://${PS4IP}:9090/status`);
xhr.send();
xhr.onerror = function(){
alert("ERRO AO CARREGAR A PAYLOAD!! , Primeiro Habilite o Servidor de Binloader nas Configurações do GOLD-HEN");
return;
};
xhr.onload = function(){
var responseJson = JSON.parse(xhr.responseText);
if (responseJson.status=="ready"){
getPayload(PLfile, function (xhr) {
if ((xhr.status === 200 || xhr.status === 304) && xhr.response) {
//Sending bins via IP POST Method
sendPayload(`http://${PS4IP}:9090`, xhr.response, function (xhr) {
if (xhr.status === 200) {
progress.innerHTML="Selecione o Próximo Payload!";
alert("Payload Carregado!!");
}else{
alert("Impossível Carregar o Payload Selecionado");
return;
}
})
}
});
}
else {
alert("Não é possível carregar o Payload porque o servidor Binloader está Ocupado!!");
return;
}
};
}