-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
100 lines (90 loc) · 3.32 KB
/
script.js
File metadata and controls
100 lines (90 loc) · 3.32 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
document.addEventListener("DOMContentLoaded", () => {
const apiKey = localStorage.getItem("apikey");
chrome.storage.local.set({ apikey: apiKey }, ()=>{});
console.log(apiKey)
const loginSection = document.getElementById("login-section");
const mainSection = document.getElementById("main-section");
if (!apiKey) {
loginSection.classList.remove("hidden");
} else {
mainSection.classList.remove("hidden");
loadAccountInfo(apiKey);
}
document.getElementById("save-apikey").addEventListener("click", () => {
const key = document.getElementById("apikey-input").value.trim();
if (key) {
localStorage.setItem("apikey", key);
chrome.storage.local.set({ apikey: apiKey }, ()=>{});
location.reload();
}
});
document.querySelectorAll(".tab").forEach(tab => {
tab.addEventListener("click", () => {
document.querySelectorAll(".tab-content").forEach(el => el.classList.add("hidden"));
document.getElementById(`${tab.dataset.tab}-tab`).classList.remove("hidden");
});
});
document.getElementById("go-dashboard").addEventListener("click", () => {
window.open("http://dash.procap.wtf/", "_blank");
});
document.getElementById("open-dashboard").addEventListener("click", () => {
window.open("http://dash.procap.wtf/", "_blank");
});
document.getElementById("topup-button").addEventListener("click", async () => {
const amount = parseFloat(document.getElementById("topup-amount").value);
if (!amount || amount <= 0) return alert("Enter a valid amount.");
const key = localStorage.getItem("apikey");
const payload = {
key: key,
quantity: amount,
product: "balance"
};
try {
const res = await fetch("http://api.procap.wtf/orders/createInvoice", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify(payload)
});
const data = await res.json();
if (data.success) {
window.open(data.invoice, "_blank");
} else {
alert("Failed to create invoice.");
}
} catch (e) {
alert("Error creating invoice.");
}
});
const toggleCheckbox = document.getElementById("toggle-funcaptcha");
chrome.storage.local.get(["solveFuncaptcha"], (result) => {
toggleCheckbox.checked = result.solveFuncaptcha || false;
});
toggleCheckbox.addEventListener("change", () => {
chrome.storage.local.set({ solveFuncaptcha: toggleCheckbox.checked });
});
});
async function loadAccountInfo(apiKey) {
const infoEl = document.getElementById("account-info");
try {
const res = await fetch("https://api.procap.wtf/users/getUser", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
key: apiKey,
showTasks: true,
limit: false
})
});
const data = await res.json();
infoEl.innerHTML = `
<p><strong>Balance:</strong> $${data.balance.toFixed(2)}</p>
<p><strong>Solved:</strong> ${data.solved}</p>
<p><strong>Threads:</strong> ${data.usedThreads}/${data.threads}</p>
<p><strong>Suspended:</strong> ${data.suspended ? "Yes" : "No"}</p>
`;
} catch (err) {
infoEl.innerHTML = "Failed to load account info.";
}
}