Your script has finished its countdown. An alert pops up in the browser tab. But you're not at your computer. The notification is useless. The true power of automation is unlocked when your digital tools can reach out and get your attention wherever you are. This is where webhooks come in.
The Missing Link: Webhooks
Think of a webhook as a special, private URL. When your script sends a message to this URL, the receiving service (like Discord or Telegram) performs an action—in our case, posting that message in a chat or channel. It's a simple yet incredibly powerful way for different applications to talk to each other.
Services like Discord and Telegram make it extremely easy to generate these webhook URLs for free. Once you have one, you have a direct line from your browser script to your phone.
Blueprint: Script to Notification
Sending a message is surprisingly simple using the modern `fetch()` API, which is built into all browsers. The process involves sending an HTTP `POST` request with your message formatted in a specific way (usually JSON).
Here is a reusable function that can send a notification to a Discord or Telegram webhook.
/**
* Sends a notification message to a specified webhook URL.
* Works for both Discord and Telegram with minor payload adjustments.
* @param {string} message - The text message you want to send.
* @param {string} webhookUrl - The webhook URL from your service.
*/
async function sendNotification(message, webhookUrl) {
// Discord and Telegram expect the message in a JSON object.
// The key is 'content' for Discord, and 'text' for Telegram.
const payload = {
content: message, // For Discord
// text: message, // For Telegram (use one or the other)
};
try {
const response = await fetch(webhookUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
if (response.ok) {
console.log('Notification sent successfully!');
} else {
console.error('Failed to send notification:', response.statusText);
}
} catch (error) {
console.error('Error sending notification:', error);
}
}
// --- Example Usage ---
const MY_WEBHOOK = 'https://discord.com/api/webhooks/your_hook_id/your_hook_token';
const upgradeName = 'Cannon lvl 14';
const timeInMilliseconds = 5 * 60 * 1000; // 5 minutes from now
setTimeout(() => {
sendNotification(`✅ Your upgrade is complete: ${upgradeName}`, MY_WEBHOOK);
}, timeInMilliseconds);
Putting It All Together
By integrating a function like this into a tool like the Time Weaver, you transform it from a passive
timer into an active alert system. When a timer created from your screenshot expires, the script doesn't
just update the UI—it calls the sendNotification function with your webhook URL.
This is the essence of true glitchmorphism: re-wiring a closed system (the game) and connecting it to the open web to build something more powerful and useful than its creators intended. You have now turned your browser into a command center that can reach you anywhere.