Add Text-to-Speech functionality; implement toggle and integrate with game titles
This commit is contained in:
1 parent
e0e870883d
commit
0a454a8061
2 files changed
+98
-5
No files matched your search
@@ -800,10 +800,32 @@
|
||||
const maturityFilterEnabled = getCookie('maturityFilter') === 'true';
|
||||
|
||||
if (maturityFilterEnabled) {
|
||||
// Hide games marked as mature
|
||||
const matureGames = document.querySelectorAll('.game.mature');
|
||||
matureGames.forEach(game => {
|
||||
game.style.display = 'none';
|
||||
// Initialize CloakJS to hide mature games
|
||||
Cloak.init({
|
||||
hideElements: ['.game.mature'], // Hide elements with the "mature" class
|
||||
debug: false, // Disable debug mode in production
|
||||
});
|
||||
}
|
||||
|
||||
// Check if Text-to-Speech is enabled
|
||||
const textToSpeechEnabled = getCookie('textToSpeech') === 'true';
|
||||
|
||||
if (textToSpeechEnabled) {
|
||||
// Function to read text aloud
|
||||
function speakText(text) {
|
||||
const speech = new SpeechSynthesisUtterance(text);
|
||||
speech.lang = 'en-US'; // Set language
|
||||
speech.rate = 1; // Set speed (1 is normal)
|
||||
speech.pitch = 1; // Set pitch (1 is normal)
|
||||
window.speechSynthesis.speak(speech);
|
||||
}
|
||||
|
||||
// Example: Add TTS to game titles
|
||||
const gameTitles = document.querySelectorAll('.game-title');
|
||||
gameTitles.forEach(title => {
|
||||
title.addEventListener('click', () => {
|
||||
speakText(title.textContent);
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
+72
-1
@@ -80,9 +80,13 @@
|
||||
<button id="toggleFPSCounter">Enable</button>
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<span>Enable Maturity Filter(comming soon)</span>
|
||||
<span>Enable Maturity Filter(comming-soon)</span>
|
||||
<button id="toggleMaturityFilter">Enable</button>
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<span>Enable Text-to-Speech</span>
|
||||
<button id="toggleTextToSpeech">Enable</button>
|
||||
</div>
|
||||
<div class="setting-item clear-cookies">
|
||||
<span>Clear Cookies</span>
|
||||
<button id="clearCookies">Clear</button>
|
||||
@@ -207,6 +211,73 @@
|
||||
|
||||
// Apply saved Maturity Filter preference on load
|
||||
applyMaturityFilterSetting(maturityFilterEnabled);
|
||||
|
||||
// Text-to-Speech Toggle
|
||||
const toggleTextToSpeechButton = document.getElementById('toggleTextToSpeech');
|
||||
const textToSpeechEnabled = getCookie('textToSpeech') === 'true';
|
||||
|
||||
function applyTextToSpeechSetting(enabled) {
|
||||
if (enabled) {
|
||||
toggleTextToSpeechButton.textContent = 'Disable';
|
||||
} else {
|
||||
toggleTextToSpeechButton.textContent = 'Enable';
|
||||
}
|
||||
}
|
||||
|
||||
toggleTextToSpeechButton.addEventListener('click', () => {
|
||||
const isTextToSpeechEnabled = getCookie('textToSpeech') === 'true';
|
||||
setCookie('textToSpeech', !isTextToSpeechEnabled, 30); // Save preference for 30 days
|
||||
applyTextToSpeechSetting(!isTextToSpeechEnabled);
|
||||
});
|
||||
|
||||
// Apply saved Text-to-Speech preference on load
|
||||
applyTextToSpeechSetting(textToSpeechEnabled);
|
||||
|
||||
// Regional Settings
|
||||
const regionSelect = document.getElementById('regionSelect');
|
||||
const savedRegion = getCookie('region') || 'us'; // Default to 'us'
|
||||
|
||||
// Set the dropdown to the saved region
|
||||
regionSelect.value = savedRegion;
|
||||
|
||||
// Save the selected region when changed
|
||||
regionSelect.addEventListener('change', () => {
|
||||
const selectedRegion = regionSelect.value;
|
||||
setCookie('region', selectedRegion, 30); // Save preference for 30 days
|
||||
alert(`Region set to: ${selectedRegion.toUpperCase()}`);
|
||||
});
|
||||
|
||||
const region = getCookie('region') || 'us'; // Default to 'us'
|
||||
|
||||
// Example: Load regional content
|
||||
if (region === 'fr') {
|
||||
document.body.innerHTML += '<p>Bienvenue! (Welcome in French)</p>';
|
||||
} else if (region === 'de') {
|
||||
document.body.innerHTML += '<p>Willkommen! (Welcome in German)</p>';
|
||||
} else if (region === 'jp') {
|
||||
document.body.innerHTML += '<p>ようこそ! (Welcome in Japanese)</p>';
|
||||
} else {
|
||||
document.body.innerHTML += '<p>Welcome!</p>';
|
||||
}
|
||||
|
||||
// Reset to Default Settings
|
||||
const resetSettingsButton = document.getElementById('resetSettings');
|
||||
|
||||
resetSettingsButton.addEventListener('click', () => {
|
||||
// Clear all cookies
|
||||
document.cookie.split(";").forEach(cookie => {
|
||||
document.cookie = cookie.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date(0).toUTCString() + ";path=/");
|
||||
});
|
||||
|
||||
// Reset UI elements to default states
|
||||
applyDarkMode(false); // Default: Light mode
|
||||
applyCloakJSSetting(false); // Default: CloakJS disabled
|
||||
applyFPSCounterSetting(false); // Default: FPS Counter disabled
|
||||
applyMaturityFilterSetting(false); // Default: Maturity Filter disabled
|
||||
applyTextToSpeechSetting(false); // Default: Text-to-Speech disabled
|
||||
|
||||
alert('Settings have been reset to default!');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
Reference in new issue
Block a user