-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
95 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head><title>YouTube live chat text2speech - options</title></head> | ||
<body> | ||
|
||
<p>Voice: <select id="voice"></select></p> | ||
<p>Emojis: <input type="checkbox" id="emojis"></p> | ||
<p id="status"></p> | ||
|
||
<script src="options.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
var voiceSelect = document.getElementById('voice'); | ||
var emojisCheck = document.getElementById('emojis'); | ||
var statusText = document.getElementById('status'); | ||
|
||
function saveChanges() { | ||
var voice = voiceSelect.options[voiceSelect.selectedIndex].value; | ||
var emojis = emojisCheck.checked; | ||
|
||
chrome.storage.sync.set({ | ||
voiceType: voice, | ||
emojisEnabled: emojis | ||
}, function() { | ||
statusText.textContent = 'Options saved. Please refresh tab with chat.'; | ||
console.log('saveChanges: voice: ' + voice + ' emojis: ' + emojis); | ||
}); | ||
} | ||
|
||
function loadOptions() { | ||
chrome.storage.sync.get({ | ||
// default values | ||
voiceType: '', | ||
emojisEnabled: true | ||
}, function(items) { | ||
console.log('loadOptions: voice: ' + items.voiceType + ' emojis: ' + items.emojisEnabled); | ||
voiceSelect.value = items.voiceType; | ||
emojisCheck.checked = items.emojisEnabled; | ||
}); | ||
} | ||
loadOptions(); | ||
|
||
voiceSelect.addEventListener('change', saveChanges); | ||
emojisCheck.addEventListener('change', saveChanges); | ||
|
||
window.speechSynthesis.onvoiceschanged = function() { | ||
var voices = speechSynthesis.getVoices(); | ||
for(i = 0; i < voices.length; i++) { | ||
var option = document.createElement('option'); | ||
option.textContent = voices[i].name + ' (' + voices[i].lang + ')'; | ||
option.value = voices[i].lang; | ||
option.setAttribute('data-name', voices[i].name); | ||
voiceSelect.appendChild(option); | ||
} | ||
console.log('Options: loaded ' + voices.length + ' voices.'); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters