Implement FPS Counter with Cookie Management Across Multiple Games

- Added functionality to display an FPS counter in various games based on a cookie setting.
- Introduced a utility function to retrieve cookies and check if the FPS counter is enabled.
- Updated the FPS calculation logic to start or hide the counter based on user preferences.
- Ensured consistent implementation across multiple HTML files, including games like "Bubble Game", "Basketball Legends", and others.
- Enhanced the main index and settings pages to manage FPS counter visibility and added a clock feature.
This commit is contained in:
2025-04-04 13:09:41 +00:00
parent 0911f12c43
commit 6014fa0de9
19 changed files with 717 additions and 293 deletions
+26
View File
@@ -91,6 +91,10 @@
<span>Enable Text-to-Speech</span>
<button id="toggleTextToSpeech">Enable</button>
</div>
<div class="setting-item">
<span>Show Date and Time</span>
<button id="toggleDateTime">Enable</button>
</div>
<div class="setting-item clear-cookies">
<span>Clear Cookies</span>
<button id="clearCookies">Clear</button>
@@ -237,6 +241,27 @@
// Apply saved Text-to-Speech preference on load
applyTextToSpeechSetting(textToSpeechEnabled);
// Date and Time Toggle
const toggleDateTimeButton = document.getElementById('toggleDateTime');
const dateTimeEnabled = getCookie('dateTime') === 'true';
function applyDateTimeSetting(enabled) {
if (enabled) {
toggleDateTimeButton.textContent = 'Disable';
} else {
toggleDateTimeButton.textContent = 'Enable';
}
}
toggleDateTimeButton.addEventListener('click', () => {
const isDateTimeEnabled = getCookie('dateTime') === 'true';
setCookie('dateTime', !isDateTimeEnabled, 30); // Save preference for 30 days
applyDateTimeSetting(!isDateTimeEnabled);
});
// Apply saved Date and Time preference on load
applyDateTimeSetting(dateTimeEnabled);
// Regional Settings
const regionSelect = document.getElementById('regionSelect');
const savedRegion = getCookie('region') || 'us'; // Default to 'us'
@@ -279,6 +304,7 @@
applyFPSCounterSetting(false); // Default: FPS Counter disabled
applyMaturityFilterSetting(false); // Default: Maturity Filter disabled
applyTextToSpeechSetting(false); // Default: Text-to-Speech disabled
applyDateTimeSetting(false); // Default: Date and Time disabled
alert('Settings have been reset to default!');
});