I have run into what I think is a hard maximum of 4 chrome.commands allowed, based on the following error I get in Google Chrome when trying to add 5 or more in the manifest.json file:
"Could not load extension from '[Extension Path]'. Too many commands specified for 'commands': The maximum is 4."
Is there any particular reason for this limit, or any way to get around it?
For context: I'm currently working on an extension that adds the current page as a bookmark to a specific folder based on a specific hotkey, currently along the lines of ctrl+alt+0, ctrl+alt+1, up to ctrl+alt+9.
You can add up to 10 shortcuts. You can also edit the existing shortcuts: just hover your mouse over one, then click the three dots that show up.
Note: At present Google Chrome only supports a maximum of 10 such website shortcuts on the Homepage. To add shortcuts manually, click on the 'Add shortcut' tile present on the homepage of Google Chrome.
I have looked at source code and figured out following lines of code.
constant declared for error message in extension_manifest_constants.cc
const char kInvalidKeyBindingTooMany[] =
"Too many commands specified for 'commands': The maximum is *.";
constant declared for maximum number of commands in extension.cc
// The maximum number of commands (including page action/browser actions) an
// extension can have.
const size_t kMaxCommandsPerExtension = 4;
and validation code in extension.cc looks for following check
if (commands - > size() > kMaxCommandsPerExtension) {
* error = ErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidKeyBindingTooMany,
base::IntToString(kMaxCommandsPerExtension));
return false;
}
Google developers marked constant to 4, so you can not add more than 4 commands for now.
Star this issue and look for developers response, if you really want to go with commands, you have to create multiple extensions with commands set of 4 for each.
Let me know if you need more information.
This is a very old question but I had a hard time finding information anywhere and this question was the top google search result for a few of my searches, so I'll add some info here.
Despite the wordage of the error, you can have as many commands as you want. This error actually refers to the number of "suggested_key" objects you can have. Chrome's documents specify the following:
An extension can have many commands but only 4 suggested keys can be specified.
So in your manifest, while you can specify additional commands, you can only give 4 of them the "suggested_key" object
"commands": {
"contains-suggested-key": {
"suggested_key": {
"default": "Ctrl+Shift+Y",
"mac": "Command+Shift+Y"
},
"description": "Toggle feature foo"
},
"NO-suggested-key": {
"description": "user must specify shortcut keys for this from the extensions page"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With