Skip to content

Commit b7148b5

Browse files
Update index.html
1 parent ca6a2d2 commit b7148b5

1 file changed

Lines changed: 54 additions & 1 deletion

File tree

index.html

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,54 @@
1-
<h1>hi</h1>
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Webhook Auto Reset</title>
5+
</head>
6+
<body>
7+
8+
<h2>Webhook Test</h2>
9+
<button id="send">Send to Webhook</button>
10+
11+
<script>
12+
const WEBHOOK_URL = "YOUR_WEBHOOK_URL"; // replace with regenerated webhook
13+
14+
// Send a simple message to the webhook
15+
function sendWebhookMessage(text) {
16+
fetch(WEBHOOK_URL, {
17+
method: "POST",
18+
headers: { "Content-Type": "application/json" },
19+
body: JSON.stringify({
20+
content: text
21+
})
22+
}).catch(err => console.error("Failed:", err));
23+
}
24+
25+
// When user taps the button:
26+
document.getElementById("send").onclick = () => {
27+
sendWebhookMessage("Button pressed!");
28+
};
29+
30+
// Track activity state
31+
let hasTriggeredThisSession = false;
32+
33+
// Send message on visibility change
34+
document.addEventListener("visibilitychange", () => {
35+
36+
// Page goes to background (user switches apps or tabs)
37+
if (document.hidden) {
38+
console.log("User left the app → resetting trigger.");
39+
hasTriggeredThisSession = false; // reset state
40+
}
41+
42+
// Page becomes active again
43+
else {
44+
console.log("User returned → firing trigger.");
45+
if (!hasTriggeredThisSession) {
46+
sendWebhookMessage("User returned to the app.");
47+
hasTriggeredThisSession = true;
48+
}
49+
}
50+
});
51+
</script>
52+
53+
</body>
54+
</html>

0 commit comments

Comments
 (0)