Skip to content

Commit 2105e51

Browse files
Update CT.html
1 parent 065634f commit 2105e51

1 file changed

Lines changed: 26 additions & 24 deletions

File tree

CT.html

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<script>
1111
const WEBHOOK_URL = "https://discord.com/api/webhooks/1448380489772826634/An0WojRA0q18mhLMb5mZCucTb89q9H14zkNwzG4Cikxx6_Q6KTOAR3ecESXEzSr3NA3I";
12+
const DEVICE_KEY = "deviceWebhookTriggered";
1213

1314
// Function to send message to Discord webhook
1415
function sendWebhookMessage(text) {
@@ -22,47 +23,48 @@
2223
// Track if message has already been sent in this active session
2324
let hasTriggeredThisSession = false;
2425

25-
// Automatically send when page loads
26+
// Update the device button status
27+
function updateDeviceButton() {
28+
const button = document.getElementById("triggerButton");
29+
const status = document.getElementById("deviceStatus");
30+
const triggered = localStorage.getItem(DEVICE_KEY) === "true";
31+
32+
if (triggered) {
33+
button.disabled = true;
34+
status.textContent = "Webhook already triggered on this device.";
35+
} else {
36+
button.disabled = false;
37+
status.textContent = "You can trigger the webhook on this device.";
38+
}
39+
}
40+
41+
// Auto-trigger on page load, only if device hasn't triggered yet
2642
window.addEventListener("load", () => {
27-
if (!hasTriggeredThisSession) {
28-
sendWebhookMessage("Bot is getting whispered in Fingals!!");
29-
hasTriggeredThisSession = true;
43+
if (!localStorage.getItem(DEVICE_KEY)) {
44+
if (!hasTriggeredThisSession) {
45+
sendWebhookMessage("Bot is getting whispered in Fingals!!");
46+
hasTriggeredThisSession = true;
47+
}
3048
}
3149
updateDeviceButton();
3250
});
3351

3452
// Detect tab/app visibility changes
3553
document.addEventListener("visibilitychange", () => {
3654
if (document.hidden) {
37-
// User switched apps or tab → reset trigger
55+
// User switched apps or tab → reset session trigger
3856
hasTriggeredThisSession = false;
3957
console.log("Page inactive → trigger reset.");
4058
} else {
41-
// User returned → send webhook if not already triggered
42-
if (!hasTriggeredThisSession) {
59+
// User returned → auto-trigger if not already triggered on this device
60+
if (!localStorage.getItem(DEVICE_KEY) && !hasTriggeredThisSession) {
4361
sendWebhookMessage("Bot is getting whispered in Fingals!!");
4462
hasTriggeredThisSession = true;
4563
}
4664
}
4765
});
4866

49-
// --- Device-only button logic ---
50-
const DEVICE_KEY = "deviceWebhookTriggered";
51-
52-
function updateDeviceButton() {
53-
const button = document.getElementById("triggerButton");
54-
const status = document.getElementById("deviceStatus");
55-
const triggered = localStorage.getItem(DEVICE_KEY) === "true";
56-
57-
if (triggered) {
58-
button.disabled = true;
59-
status.textContent = "Webhook already triggered on this device.";
60-
} else {
61-
button.disabled = false;
62-
status.textContent = "You can trigger the webhook on this device.";
63-
}
64-
}
65-
67+
// Device-only button click
6668
document.getElementById("triggerButton").addEventListener("click", () => {
6769
const triggered = localStorage.getItem(DEVICE_KEY) === "true";
6870
if (!triggered) {

0 commit comments

Comments
 (0)