|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <title>Webhook Auto Trigger</title> |
| 5 | + <style> |
| 6 | + body { |
| 7 | + font-family: Arial, sans-serif; |
| 8 | + display: flex; |
| 9 | + justify-content: center; |
| 10 | + align-items: center; |
| 11 | + min-height: 100vh; |
| 12 | + margin: 0; |
| 13 | + background: #f0f0f0; |
| 14 | + } |
| 15 | + .container { |
| 16 | + background: white; |
| 17 | + padding: 30px; |
| 18 | + border-radius: 10px; |
| 19 | + box-shadow: 0 2px 10px rgba(0,0,0,0.1); |
| 20 | + text-align: center; |
| 21 | + } |
| 22 | + input { |
| 23 | + padding: 10px; |
| 24 | + font-size: 16px; |
| 25 | + border: 2px solid #ddd; |
| 26 | + border-radius: 5px; |
| 27 | + width: 200px; |
| 28 | + margin: 10px 0; |
| 29 | + } |
| 30 | + button { |
| 31 | + padding: 10px 20px; |
| 32 | + font-size: 16px; |
| 33 | + background: #5865F2; |
| 34 | + color: white; |
| 35 | + border: none; |
| 36 | + border-radius: 5px; |
| 37 | + cursor: pointer; |
| 38 | + } |
| 39 | + button:hover { |
| 40 | + background: #4752C4; |
| 41 | + } |
| 42 | + button:disabled { |
| 43 | + background: #ccc; |
| 44 | + cursor: not-allowed; |
| 45 | + } |
| 46 | + .status { |
| 47 | + margin-top: 15px; |
| 48 | + font-weight: bold; |
| 49 | + } |
| 50 | + .success { color: green; } |
| 51 | + .error { color: red; } |
| 52 | + .info { color: #5865F2; } |
| 53 | + </style> |
| 54 | +</head> |
| 55 | +<body> |
| 56 | + <div class="container" id="authContainer"> |
| 57 | + <h2>Webhook Authorization</h2> |
| 58 | + <p>Enter access code to enable auto-trigger:</p> |
| 59 | + <input type="password" id="codeInput" placeholder="Enter code" /> |
| 60 | + <br> |
| 61 | + <button id="submitCode">Submit</button> |
| 62 | + <p class="status" id="authStatus"></p> |
| 63 | + </div> |
| 64 | + |
| 65 | + <div class="container" id="activeContainer" style="display: none;"> |
| 66 | + <h2>✓ Auto-Trigger Enabled</h2> |
| 67 | + <p class="status success">This device is authorized and will auto-trigger webhooks.</p> |
| 68 | + <button id="revokeAccess">Revoke Access</button> |
| 69 | + </div> |
| 70 | + |
| 71 | +<script> |
| 72 | +const WEBHOOK_URL = "https://discord.com/api/webhooks/1448486806885503108/RKW4Xky283xWQ0zTAcwpwUafXW_oUI-Pdsm-nkgUQ3aBMEjA4eP2dzIp_i_iYbaWf-JK"; |
| 73 | +const CORRECT_CODE = "4112"; |
| 74 | +const AUTH_KEY = "webhookAuthorized"; |
| 75 | +const DEVICE_ID_KEY = "uniqueDeviceId"; |
| 76 | + |
| 77 | +// Generate or retrieve unique device ID |
| 78 | +function getDeviceId() { |
| 79 | + let deviceId = localStorage.getItem(DEVICE_ID_KEY); |
| 80 | + if (!deviceId) { |
| 81 | + deviceId = 'device_' + Math.random().toString(36).substr(2, 9) + Date.now().toString(36); |
| 82 | + localStorage.setItem(DEVICE_ID_KEY, deviceId); |
| 83 | + } |
| 84 | + return deviceId; |
| 85 | +} |
| 86 | + |
| 87 | +// Check if device is authorized |
| 88 | +function isAuthorized() { |
| 89 | + return localStorage.getItem(AUTH_KEY) === "true"; |
| 90 | +} |
| 91 | + |
| 92 | +// Function to send message to Discord webhook |
| 93 | +function sendWebhookMessage(text) { |
| 94 | + const deviceId = getDeviceId(); |
| 95 | + const message = `${text}\nDevice: ${deviceId}`; |
| 96 | + |
| 97 | + fetch(WEBHOOK_URL, { |
| 98 | + method: "POST", |
| 99 | + headers: { "Content-Type": "application/json" }, |
| 100 | + body: JSON.stringify({ content: message }) |
| 101 | + }).catch(err => console.error("Webhook error:", err)); |
| 102 | +} |
| 103 | + |
| 104 | +// Track if message has already been sent in this session |
| 105 | +let hasTriggeredThisSession = false; |
| 106 | + |
| 107 | +// Trigger webhook if authorized |
| 108 | +function triggerIfAuthorized() { |
| 109 | + if (isAuthorized() && !hasTriggeredThisSession) { |
| 110 | + sendWebhookMessage("Bot is getting whispered first Shalemont Bot!!"); |
| 111 | + hasTriggeredThisSession = true; |
| 112 | + } |
| 113 | +} |
| 114 | + |
| 115 | +// Update UI based on authorization status |
| 116 | +function updateUI() { |
| 117 | + const authContainer = document.getElementById("authContainer"); |
| 118 | + const activeContainer = document.getElementById("activeContainer"); |
| 119 | + |
| 120 | + if (isAuthorized()) { |
| 121 | + authContainer.style.display = "none"; |
| 122 | + activeContainer.style.display = "block"; |
| 123 | + } else { |
| 124 | + authContainer.style.display = "block"; |
| 125 | + activeContainer.style.display = "none"; |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +// Submit code |
| 130 | +document.getElementById("submitCode").addEventListener("click", () => { |
| 131 | + const input = document.getElementById("codeInput"); |
| 132 | + const status = document.getElementById("authStatus"); |
| 133 | + |
| 134 | + if (input.value === CORRECT_CODE) { |
| 135 | + localStorage.setItem(AUTH_KEY, "true"); |
| 136 | + status.textContent = "✓ Access granted!"; |
| 137 | + status.className = "status success"; |
| 138 | + setTimeout(() => { |
| 139 | + updateUI(); |
| 140 | + triggerIfAuthorized(); |
| 141 | + }, 1000); |
| 142 | + } else { |
| 143 | + status.textContent = "✗ Invalid code"; |
| 144 | + status.className = "status error"; |
| 145 | + input.value = ""; |
| 146 | + } |
| 147 | +}); |
| 148 | + |
| 149 | +// Allow Enter key to submit |
| 150 | +document.getElementById("codeInput").addEventListener("keypress", (e) => { |
| 151 | + if (e.key === "Enter") { |
| 152 | + document.getElementById("submitCode").click(); |
| 153 | + } |
| 154 | +}); |
| 155 | + |
| 156 | +// Revoke access |
| 157 | +document.getElementById("revokeAccess").addEventListener("click", () => { |
| 158 | + localStorage.removeItem(AUTH_KEY); |
| 159 | + hasTriggeredThisSession = false; |
| 160 | + updateUI(); |
| 161 | +}); |
| 162 | + |
| 163 | +// Auto-trigger on page load if authorized |
| 164 | +window.addEventListener("load", () => { |
| 165 | + updateUI(); |
| 166 | + triggerIfAuthorized(); |
| 167 | +}); |
| 168 | + |
| 169 | +// Tab visibility change |
| 170 | +document.addEventListener("visibilitychange", () => { |
| 171 | + if (document.hidden) { |
| 172 | + hasTriggeredThisSession = false; |
| 173 | + console.log("Page inactive → session reset."); |
| 174 | + } else { |
| 175 | + triggerIfAuthorized(); |
| 176 | + } |
| 177 | +}); |
| 178 | +</script> |
| 179 | +</body> |
| 180 | +</html> |
0 commit comments