Made more adjustments to the spam protection.
This commit is contained in:
parent
6418e37d67
commit
4cd41100fd
1 changed files with 31 additions and 49 deletions
80
index.html
80
index.html
|
@ -182,14 +182,10 @@
|
|||
|
||||
<div id="warningModal" class="modal warning-modal">
|
||||
<div class="modal-content">
|
||||
<span class="close-button" style="display: none">×</span>
|
||||
<h2>⚠️ Slow Down!</h2>
|
||||
<p>Clicking too quickly may get you flagged as spam by Wiby.me.</p>
|
||||
<p>Please wait a moment between fumbles.</p>
|
||||
<div id="cooldownTimer" class="cooldown-timer">
|
||||
You can close this warning in: <span id="cooldownSeconds">5</span>s
|
||||
</div>
|
||||
<button id="warningCloseBtn" class="warning-close-btn" disabled>
|
||||
<h2>⚠️ Rate Limited</h2>
|
||||
<p>To protect Wiby.me from excessive requests, fumbling is limited to 20 times per minute.</p>
|
||||
<p>Please wait <span id="cooldownSeconds">0</span> seconds before fumbling again.</p>
|
||||
<button id="warningCloseBtn" class="warning-close-btn">
|
||||
I Understand
|
||||
</button>
|
||||
</div>
|
||||
|
@ -218,57 +214,43 @@
|
|||
}
|
||||
|
||||
let lastFumbleTime = 0;
|
||||
const warningThreshold = 3; // Trigger warning after 3 rapid fumbles
|
||||
const rapidPeriod = 5000; // 5 second window for counting rapid fumbles
|
||||
const resetPeriod = 3000; // Reset counter if no rapid fumbles in 3 seconds
|
||||
let fumbleTimes = []; // Track timestamps of recent fumbles
|
||||
let cooldownTimer = null;
|
||||
const minInterval = 2000; // Minimum 2 seconds between fumbles
|
||||
const maxPerMinute = 20; // Maximum 20 fumbles per minute
|
||||
let recentFumbles = []; // Track fumble timestamps for rate limiting
|
||||
|
||||
const fumble = () => {
|
||||
const currentTime = Date.now();
|
||||
const timeSinceLastFumble = currentTime - lastFumbleTime;
|
||||
|
||||
// Add current fumble time and remove old ones (older than 5 seconds)
|
||||
fumbleTimes.push(currentTime);
|
||||
fumbleTimes = fumbleTimes.filter(time => currentTime - time < rapidPeriod);
|
||||
|
||||
// If we have 3 or more fumbles within 5 seconds, show warning
|
||||
if (fumbleTimes.length >= warningThreshold) {
|
||||
// Show warning modal
|
||||
const warningModal = document.getElementById('warningModal');
|
||||
const cooldownSeconds = document.getElementById('cooldownSeconds');
|
||||
const closeBtn = document.getElementById('warningCloseBtn');
|
||||
warningModal.classList.add('show');
|
||||
closeBtn.disabled = true;
|
||||
|
||||
// Update countdown timer
|
||||
let remainingTime = 5;
|
||||
cooldownSeconds.textContent = remainingTime;
|
||||
|
||||
if (cooldownTimer) clearInterval(cooldownTimer);
|
||||
cooldownTimer = setInterval(() => {
|
||||
remainingTime--;
|
||||
|
||||
if (remainingTime <= 0) {
|
||||
cooldownSeconds.textContent = '0';
|
||||
closeBtn.disabled = false;
|
||||
clearInterval(cooldownTimer);
|
||||
fumbleTimes = []; // Reset fumble history
|
||||
} else {
|
||||
cooldownSeconds.textContent = remainingTime;
|
||||
}
|
||||
}, 1000);
|
||||
// Prevent rapid clicks (2 second minimum interval)
|
||||
if (timeSinceLastFumble < minInterval) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If there are 2 fumbles, check if they're more than 3 seconds apart
|
||||
if (fumbleTimes.length >= 2) {
|
||||
const lastTwoInterval = fumbleTimes[fumbleTimes.length - 1] - fumbleTimes[fumbleTimes.length - 2];
|
||||
if (lastTwoInterval > resetPeriod) {
|
||||
fumbleTimes = [currentTime]; // Reset to just the current fumble
|
||||
}
|
||||
// Clean up old fumbles (older than 1 minute)
|
||||
recentFumbles = recentFumbles.filter(time =>
|
||||
currentTime - time < 60000
|
||||
);
|
||||
|
||||
// Check rate limit (20 per minute)
|
||||
if (recentFumbles.length >= maxPerMinute) {
|
||||
const warningModal = document.getElementById('warningModal');
|
||||
const cooldownSeconds = document.getElementById('cooldownSeconds');
|
||||
warningModal.classList.add('show');
|
||||
|
||||
// Calculate remaining cooldown time
|
||||
const oldestFumble = recentFumbles[0];
|
||||
const cooldownRemaining = Math.ceil((60000 - (currentTime - oldestFumble)) / 1000);
|
||||
cooldownSeconds.textContent = cooldownRemaining;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Record this fumble
|
||||
lastFumbleTime = currentTime;
|
||||
recentFumbles.push(currentTime);
|
||||
|
||||
// Perform the fumble
|
||||
const frame = document.getElementById("contentFrame");
|
||||
frame.src = "https://wiby.me/surprise/";
|
||||
|
||||
|
|
Loading…
Reference in a new issue