-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeybrowser-back.js
More file actions
29 lines (26 loc) · 1.03 KB
/
keybrowser-back.js
File metadata and controls
29 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
let gettingAllCommands = browser.commands.getAll();
gettingAllCommands.then((commands) => {
for (let command of commands) {
// Note that this logs to the Add-on Debugger's console: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Debugging
// not the regular Web console.
console.log(command);
}
});
browser.commands.onCommand.addListener(
function(command) {
if (command.substr(0, 7) == "keynav-") {
sendCommandToCurrentTab(command.substr(7));
}
});
function sendCommandToCurrentTab(command){
/*
var args = Array.prototype.slice.call(arguments); //Get arguments as an array
return browser.tabs.query({active:true,currentWindow:true}).then(function(tabs){
args.unshift(tabs[0].id); //Add tab ID to be the new first argument.
return browser.tabs.sendMessage.apply(this,args);
});
*/
browser.tabs.query({active: true, currentWindow: true}, function(tabs){
browser.tabs.sendMessage(tabs[0].id, { keynav: command}, function(response) {});
});
}