Skip to content

Commit

Permalink
Added reload page command and bug where link number covered down arro…
Browse files Browse the repository at this point in the history
…w on google search results
  • Loading branch information
rjfc committed Apr 16, 2020
1 parent a36cef6 commit 59e4a77
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "NaviVoice: Voice Input Productivity Assistant",
"short_name": "NaviVoice",
"description": "Surf the web with just your voice!",
"version": "0.2.3",
"version": "0.2.4",
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",

"browser_action": {
Expand Down
20 changes: 18 additions & 2 deletions scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ else {
});*/
chrome.tabs.executeScript(null, {file: "scripts/jquery-3.1.1.min.js"}, function () {
chrome.tabs.executeScript({
code: "$('a').html(function(index, html) { return html + '[' + (index + 1) + ']'; })"
code: "$('a').html(function(index, html) { return html + \"<span style='background-color:white;position:absolute;z-index:100;'>[\" + (index + 1) + \"]</span>\"; })"
});
});
utterance = new SpeechSynthesisUtterance("Listing links.");
Expand Down Expand Up @@ -355,6 +355,14 @@ else {
else if (event.results[i][0].transcript.toLowerCase().trim() == ("chrome")) {
utterance = new SpeechSynthesisUtterance(whatResponses[Math.floor(Math.random()*whatResponses.length)]);
}
// chrome reload
else if (event.results[i][0].transcript.toLowerCase().trim().substr(7, event.results[i][0].transcript.trim().length - 1) == "reload") {
chrome.tabs.query({active: true, currentWindow: true}, function (arrayOfTabs) {
var code = 'window.location.reload();';
chrome.tabs.executeScript(arrayOfTabs[0].id, {code: code});
});
}
// chrome stop listening
else if (event.results[i][0].transcript.toLowerCase().trim().includes("stop listening")) {
chrome.management.getSelf(function(result) {
chrome.management.setEnabled(result.id, false)
Expand Down Expand Up @@ -626,7 +634,7 @@ else {
});*/
chrome.tabs.executeScript(null, {file: "scripts/jquery-3.1.1.min.js"}, function () {
chrome.tabs.executeScript({
code: "$('a').html(function(index, html) { return html + '[' + (index + 1) + ']'; })"
code: "$('a').html(function(index, html) { return html + \"<span style='background-color:white;position:absolute;z-index:100;'>[\" + (index + 1) + \"]</span>\"; })"
});
});
utterance = new SpeechSynthesisUtterance("Listing links.");
Expand Down Expand Up @@ -662,6 +670,14 @@ else {
});
utterance = new SpeechSynthesisUtterance("Showing you your downloads.");
}
// reload
else if (event.results[i][0].transcript.toLowerCase().trim() == "reload") {
chrome.tabs.query({active: true, currentWindow: true}, function (arrayOfTabs) {
var code = 'window.location.reload();';
chrome.tabs.executeScript(arrayOfTabs[0].id, {code: code});
});
}
// stop listesning
else if (event.results[i][0].transcript.toLowerCase().trim().includes("stop listening")) {
chrome.management.getSelf(function(result) {
chrome.management.setEnabled(result.id, false)
Expand Down

0 comments on commit 59e4a77

Please sign in to comment.