-
Notifications
You must be signed in to change notification settings - Fork 0
/
bloxflip-notifier.user.js
88 lines (78 loc) · 3.1 KB
/
bloxflip-notifier.user.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
88
// ==UserScript==
// @name Bloxflip Rain Notifier with Webhook
// @namespace http://tampermonkey.net/
// @version 1.3.3
// @description Notify about rain and send to Discord Webhook!
// @author Valentineuh
// @match https://bloxflip.com/*
// @icon https://bloxflip.com/favicon.ico
// @license MIT
// @grant GM_xmlhttpRequest
// ==/UserScript==
let raining = false;
let testMode = false;
const WEBHOOK_URL = "https://discord.com/api/webhooks/1278496948403572767/DPrvuwq1nQ_F7--AeMegsjbddoucn4acAOuAORmePCtD1uLfl0z_oZyjbOUdwewPDS7s";
if (Notification.permission !== 'granted') {
Notification.requestPermission();
}
setTimeout(() => {
setInterval(async () => {
let data;
if (testMode) {
data = {
rain: {
active: true,
prize: 150000,
created: Date.now(),
duration: 300000,
players: ["Black Bear", "Bee Bear", "Onett"],
host: "BeeSwarmOnTop"
}
};
} else {
data = await (await fetch('https://api.bloxflip.com/chat/history')).json();
}
let prize = data.rain.prize;
let host = data.rain.host;
let createdTime = new Date(data.rain.created);
let duration = data.rain.duration;
let endTime = new Date(createdTime.getTime() + duration);
let discordEndTime = `<t:${Math.floor(endTime.getTime() / 1000)}:R>`;
if (data.rain.active && !raining) {
raining = true;
if (Notification.permission === 'granted') {
new Notification("Rain detected! 😋", {
body: `Rain has started! Prize: ${prize}$ bobux. Host: ${host}`,
icon: "https://raw.githubusercontent.com/valxe/bloxflip-rain-joiner/main/icone.png"
});
}
sendToWebhook({
title: "Rain detected! 😋",
description: `Rain has started!\nPrize: **${prize}$ bobux**.\nHost: **${host}**\nEnds: **${discordEndTime}**`,
color: 7618473,
thumbnail: { url: "https://raw.githubusercontent.com/RadianeData/radianedata/main/assets/45497981.png" },
footer: {
text: "Bloxflip Rain Notifier",
icon_url: "https://raw.githubusercontent.com/valxe/bloxflip-rain-joiner/main/icone.png"
}
});
} else if (!data.rain.active && raining) {
raining = false;
}
}, 10000);
}, 5000);
function sendToWebhook(embed) {
GM_xmlhttpRequest({
method: "POST",
url: WEBHOOK_URL,
headers: { "Content-Type": "application/json" },
data: JSON.stringify({ embeds: [embed] }),
onload: function (response) {
if (response.status === 204) {
console.log("Embed sent to Discord webhook successfully!");
} else {
console.error("Failed to send embed to Discord webhook:", response.status, response.statusText);
}
}
});
}