Sample chrome.commands.extension

This commit is contained in:
Matthew Wein
2016-03-07 15:21:01 -08:00
parent df875e0189
commit 3feec32b67
3 changed files with 42 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
# open-my-page
This extension includes:
* a background script, "background.js"
All it does is: registers a shortcut (Ctrl+Shift+Y) to send an onCommand event (Command+Shift+Y on a Mac).",
It shows:
* how to use chrome.commands to register a keyboard shortcut for your extension.
+10
View File
@@ -0,0 +1,10 @@
browser.commands.getAll(function(commands) {
commands.forEach(function(command) {
console.log(command);
});
});
browser.commands.onCommand.addListener(function(command) {
console.log("onCommand event received for message: ", command);
});
+21
View File
@@ -0,0 +1,21 @@
{
"name": "Sample Commands Extension",
"description": "Press Ctrl+Shift+Y to send an event (Command+Shift+Y on a Mac).",
"homepage_url": "https://github.com/mdn/webextensions-examples/tree/master/commands",
"manifest_version": 2,
"version": "1.0",
"background": {
"scripts": ["background.js"]
},
"applications": {
"gecko": {
"id": "commands@mozilla.org"
}
},
"commands": {
"toggle-feature": {
"suggested_key": { "default": "Ctrl+Shift+Y" },
"description": "Send a 'toggle-feature' event to the extension"
}
}
}