-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuncaptcha.js
87 lines (76 loc) · 3.28 KB
/
funcaptcha.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
84
85
86
87
const script = document.createElement("script");
script.src = chrome.runtime.getURL("funcaptchaRequestInterceptor.js");
script.onload = function () {
this.remove();
};
(document.head || document.documentElement).appendChild(script);
let gfctResponse = null;
window.addEventListener("message", (event) => {
if (event.source !== window) return;
if (event.data?.type === "gfct-response" && !gfctResponse) {
gfctResponse = JSON.parse(event.data.body);
chrome.runtime.sendMessage({ type: "gfct-response", data: gfctResponse });
}
});
const urls = new Set();
document.addEventListener("DOMContentLoaded", () => {
const observer = new MutationObserver(async() => {
const btn = document.querySelector('button[data-theme="home.verifyButton"]');
if (btn) {
btn.click();
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
chrome.runtime.onMessage.addListener(async(msg, sender, sendResponse) => {
if (msg.type === "rtig-image") {
chrome.storage.local.get(["solveFuncaptcha"], (result) => {
if (!result.solveFuncaptcha) {
return;
}
chrome.runtime.sendMessage({ type: "get-gfct-response" }, (response) => {
gfctResponse = response.gfctResponse;
const cleanedUrl = decodeURI(msg.url);
if (urls.has(cleanedUrl)) {
return;
}
urls.add(cleanedUrl);
const rightArrow = document.querySelector("a.right-arrow");
chrome.runtime.sendMessage({ type: "get-api-key" }, (response) => {
const apiKey = response.apikey;
if (!apiKey) return alert("❌ No API key found.");
const xhr = new XMLHttpRequest();
xhr.open("POST", "https://api.procap.wtf/solve", true);
xhr.setRequestHeader("Content-Type", "application/json");
const body = JSON.stringify({
key: apiKey,
images: [msg.base64.split(";base64,")[1]],
captchaType: "funcaptchaClassification",
variant: gfctResponse.game_data.instruction_string
});
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
try {
const data = JSON.parse(xhr.responseText);
const solution = data.solution[0];
for (let i = 0; i < solution; i++) {
rightArrow?.click();
}
document.querySelector("button.sc-nkuzb1-0.yuVdl.button")?.click();
} catch (e) {
console.error("❌ JSON parse error:", e);
}
}
}
};
xhr.send(body);
});
});
});
}
});