0% found this document useful (0 votes)
31 views

Message

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Message

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

// ==UserScript==

// @name Rain Event Joiner for Wildbet


// @namespace http://tampermonkey.net/
// @version 1
// @description Detects rain events, solves hCaptcha, and joins the event
automatically
// @author You
// @match *://wildbet.gg/*
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Configuration
const apiKey = 'c7d4accb8b183aff4e0969b0cfb7e9a6'; // Replace with your
2Captcha API key
const siteKey = '4c1c3cad-00ab-4e76-b0e3-e79258cdaa06'; // The site key for
hCaptcha
const pageUrl = 'https://wildbet.gg'; // The URL of the page with the captcha
const webhookUrl =
'https://discord.com/api/webhooks/1004671307776020540/zZIBKNW4N9P2TxtoE2xURgu0zbwa_
yREck1fT93bPw28QndfvvWVtUthlFC9MYnKubNZ'; // Replace with your webhook URL
console.log('RAINZ MASTER IS ON BABY!');

let ws;
let rainEventDetected = false; // To track if a rain event was detected
let reconnectTimeout = 5000; // Default reconnect timeout

const connectWebSocket = () => {


ws = new WebSocket("wss://wildbet.gg/socket.io/?
EIO=4&transport=websocket");

// WebSocket message handling


ws.onmessage = function(e) {
try {
const messageData = e.data;
if (messageData.startsWith('0{"sid":"')) {
console.log('Received initial SID message:', messageData);
} else if (messageData.startsWith('40{"sid":"')) {
console.log('Received second SID message:', messageData);
authenticateWebSocket();
} else if (messageData.startsWith('42["authenticationResponse"')) {
const msg =
JSON.parse(messageData.slice(messageData.indexOf('[')));
const eventData = msg[1];
console.log('Authentication response received:', eventData);

if (eventData && eventData.events && eventData.events.rain) {


const potDetails = eventData.events.rain.pot;
console.log('Rain event detected with details:',
potDetails);

if (potDetails && potDetails.state === "ENDING") {


const eventId = potDetails.id; // Extract the event ID
console.log(`Rain event ID: ${eventId}, Prize: $
{potDetails.prize}`);
sendWebhook(`Rain event detected with ID: ${eventId},
Prize: ${potDetails.prize}`);
solveCaptcha(siteKey, pageUrl)
.then(captchaToken => {
console.log('Captcha solved, joining rain
event...');
joinRainEvent(captchaToken, eventId);
})
.catch(error => console.error('Error solving
captcha:', error));
} else {
console.log('Rain event not in ENDING state.');
}
}

// Close and reconnect after processing the response


if (ws.readyState === WebSocket.OPEN) {
ws.close();
}
if (rainEventDetected) {
reconnectTimeout = 120000; // 2 minutes if a rain event was
detected
} else {
reconnectTimeout = 5000; // 5 seconds otherwise
}
setTimeout(connectWebSocket, reconnectTimeout);
}
} catch (error) {
console.error('Error parsing WebSocket message:', error);
}
};

// Handle WebSocket errors and reconnections


ws.onerror = function(error) {
console.error('WebSocket error:', error);
};

ws.onclose = function() {
console.log('WebSocket connection closed.');
};

// Authenticate with the WebSocket server


const authenticateWebSocket = () => {
const date1 = +new Date();
const authToken = localStorage.getItem('authToken'); // Get the
authToken from local storage
if (authToken) {
ws.send(`42["authentication",{"authToken":"$
{authToken}","clientTime":${date1}}]`);
console.log('Authentication message sent with authToken:',
authToken);
} else {
console.error('AuthToken not found in local storage!');
}
};

// Initial WebSocket connection


ws.onopen = function() {
console.log('WebSocket connection opened.');
ws.send('40');
};
};

// Initial WebSocket connection


connectWebSocket();

// Function to solve hCaptcha using 2Captcha


function solveCaptcha(siteKey, pageUrl) {
return new Promise((resolve, reject) => {
const apiUrl = `http://2captcha.com/in.php?key=$
{apiKey}&method=hcaptcha&sitekey=${siteKey}&pageurl=${pageUrl}&json=1`;
console.log('Sending captcha challenge to 2Captcha:', apiUrl);
fetch(apiUrl)
.then(response => response.json())
.then(data => {
if (data.status === 1) {
console.log('Captcha challenge sent to 2Captcha, polling
for solution...');
const requestId = data.request;
const resultUrl = `http://2captcha.com/res.php?key=$
{apiKey}&action=get&id=${requestId}&json=1`;
const intervalId = setInterval(() => {
fetch(resultUrl)
.then(response => response.json())
.then(data => {
if (data.status === 1) {
clearInterval(intervalId);
console.log('Captcha solved, solution token
received.');
resolve(data.request); // Resolve with the
solution token
} else if (data.request !== 'CAPCHA_NOT_READY')
{
clearInterval(intervalId);
reject(new Error('2Captcha error: ' +
data.request));
}
})
.catch(error => {
clearInterval(intervalId);
console.error('Error polling captcha
solution:', error);
reject(error);
});
}, 5000); // Check every 5 seconds
} else {
reject(new Error('2Captcha error: ' + data.request));
}
})
.catch(error => {
console.error('Error sending captcha challenge to 2Captcha:',
error);
reject(error);
});
});
}

// Function to join the rain event


function joinRainEvent(captchaToken, eventId) {
setTimeout(() => { // Wait 5 seconds before trying to join the rain event
const joinUrl = 'https://wildbet.gg/api/events/rain/join';
const authToken = localStorage.getItem('authToken'); // Get the
authToken from local storage
const payload = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${authToken}`
},
body: JSON.stringify({
captchaToken: captchaToken,
i1oveu: true,
potId: eventId
})
};

fetch(joinUrl, payload)
.then(response => response.json())
.then(data => {
if (data.success && data.message ===
'API_EVENTS_RAIN_JOINSUCCESSFUL') {
console.log('Joined rain successfully.');
sendWebhook(`Joined rain event with ID: ${eventId}
successfully.`);
rainEventDetected = true; // Set flag to wait 2 minutes
before reconnecting
} else {
console.error('Failed to join rain:', data);
}
})
.catch(error => console.error('Error joining rain event:', error));
}, 5000);
}

// Function to send a webhook notification


function sendWebhook(message) {
const payload = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ content: message })
};

fetch(webhookUrl, payload)
.then(response => {
if (response.ok) {
console.log('Webhook notification sent successfully.');
} else {
console.error('Failed to send webhook notification.');
}
})
.catch(error => console.error('Error sending webhook notification:',
error));
}

})();

You might also like