Skip to content

Commit 32d5f4d

Browse files
committed
Initial commit
0 parents  commit 32d5f4d

14 files changed

+247
-0
lines changed

background.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Document</title>
6+
</head>
7+
<body>
8+
<script src="js/background.js"></script>
9+
</body>
10+
</html>

dashboard.html

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
<style type="text/css" href="js/bootstrap.min.css"></style>
9+
</head>
10+
<body>
11+
<script src="js/jquery-3.3.1.min.js"></script>
12+
<script src="js/optionpage.js"></script>
13+
<div style="width: 400px">
14+
<div class="container">
15+
<table width="100%" class="table table-responsive">
16+
<tr>
17+
<td>Pitch</td>
18+
<td>:</td>
19+
<td>
20+
<select name="pitch" id="pitch">
21+
<option value="0.25">0.25</option>
22+
<option value="0.5">0.5</option>
23+
<option value="1" selected>1</option>
24+
<option value="1.25">1.25</option>
25+
<option value="1.5">1.5</option>
26+
<option value="2">2</option>
27+
</select>
28+
</td>
29+
</tr>
30+
31+
<tr>
32+
<td>Rate</td>
33+
<td>:</td>
34+
<td>
35+
<select name="rate" id="rate">
36+
<option value="0.25">0.25</option>
37+
<option value="0.5">0.5</option>
38+
<option value="1" selected>1</option>
39+
<option value="1.25">1.25</option>
40+
<option value="1.5">1.5</option>
41+
<option value="2">2</option>
42+
</select>
43+
</td>
44+
</tr>
45+
46+
<tr>
47+
<td>Volume</td>
48+
<td>:</td>
49+
<td>
50+
<select name="volume" id="volume">
51+
<option value="0.1">1</option>
52+
<option value="0.2">2</option>
53+
<option value="0.3">3</option>
54+
<option value="0.4">4</option>
55+
<option value="0.5">5</option>
56+
<option value="0.6">6</option>
57+
<option value="0.7">7</option>
58+
<option value="0.8">8</option>
59+
<option value="0.9">9</option>
60+
<option value="1" selected="">10</option>
61+
</select>
62+
</td>
63+
</tr>
64+
65+
<tr>
66+
<td>&nbsp;</td>
67+
<td>&nbsp;</td>
68+
<td>&nbsp;</td>
69+
</tr>
70+
<tr>
71+
<td>&nbsp;</td>
72+
<td>
73+
<button id="default">Default Config</button>
74+
</td>
75+
<td>
76+
<button id="save">Save Config</button>
77+
</td>
78+
</tr>
79+
</table>
80+
</div>
81+
</div>
82+
</body>
83+
</html>

img/icon_128.png

18 KB
Loading

img/icon_16.png

1.05 KB
Loading

img/icon_32.png

2.92 KB
Loading

img/icon_64.png

7.88 KB
Loading

js/background.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
(function () {
2+
contextMenu = {
3+
"id": "text-to-voice",
4+
"title": "Text to voice",
5+
"contexts": ["selection"],
6+
"visible": true,
7+
};
8+
chrome.contextMenus.create(contextMenu);
9+
})();
10+
(function () {
11+
chrome.runtime.onMessage.addListener(
12+
function (request, sender, sendResponse) {
13+
console.log(sender.tab ?
14+
"from a content script:" + sender.tab.url :
15+
"from the extension");
16+
if (request.greeting == "hello")
17+
sendResponse({farewell: "goodbye"});
18+
});
19+
})();
20+
21+
chrome.contextMenus.onClicked.addListener(function (info, tab) {
22+
chrome.tabs.sendMessage(tab.id, {
23+
action: 'speak',
24+
});
25+
26+
return true;
27+
})
28+
(function () {
29+
30+
31+
chrome.commands.onCommand.addListener(function (command) {
32+
if (command === "start-ttl") {
33+
chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
34+
chrome.tabs.sendMessage(tabs[0].id, {
35+
action: 'speak',
36+
});
37+
});
38+
}
39+
if (command === "stop-ttl") {
40+
chrome.ttl.stop();
41+
}
42+
console.log('Command:', command);
43+
});
44+
})();

js/bootstrap.min.css

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/bootstrap.min.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/content.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
2+
if (msg.action === "speak") {
3+
chrome.storage.sync.get("settings", function (s) {
4+
obj = new SpeechSynthesisUtterance(window.getSelection().toString(), "", null, s.settings.volume, s.settings.rate, s.settings.pitch);
5+
window.speechSynthesis.speak(obj);
6+
});
7+
}
8+
if (msg.action === "getAllVoice") {
9+
sendResponse(window.speechSynthesis.getVoices());
10+
}
11+
12+
});

0 commit comments

Comments
 (0)