Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample for chrome.commands API #1126

Open
hrmtsh2 opened this issue Mar 17, 2024 · 5 comments
Open

Sample for chrome.commands API #1126

hrmtsh2 opened this issue Mar 17, 2024 · 5 comments

Comments

@hrmtsh2
Copy link

hrmtsh2 commented Mar 17, 2024

I would like to write a sample for chrome.commands.
The idea is to have keyboard shortcuts trigger dark/light mode (through content script injection). It could have different shortcuts for different functionalities (say, one for dark mode and another for embedding reading time estimate).
@oliverdunk @jpmedley kindly give suggestions or the go-ahead.

@GoogleChrome GoogleChrome deleted a comment from Yahelpro Mar 20, 2024
@hrmtsh2
Copy link
Author

hrmtsh2 commented Mar 28, 2024

Realised that many samples already use commands (albeit not custom commands). Closing issue

@hrmtsh2 hrmtsh2 closed this as completed Mar 28, 2024
@kalpanmukherjee
Copy link

hi @hrmtsh2, could you point me towards any of these samples? much appreciated

@hrmtsh2
Copy link
Author

hrmtsh2 commented May 20, 2024

Well, coming back to this issue, I have been unable to find a single sample that explicitly uses the "command" property in the manifest (I swear I saw many when I closed the issue!). Even if there were, it was certainly small in number, and many samples do not, in fact, demonstrate the commands API.
I suppose one could do this by either incorporating it into existing samples, or by creating a new (set of) api-samples for it.
So I will reopen this issue.

@hrmtsh2 hrmtsh2 reopened this May 20, 2024
@oliverdunk
Copy link
Member

Hi @hrmtsh2, an example of an extension using the manifest declaration would be this one: https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/api-samples/default_command_override

The only thing I don't see right now is an example of an extension using the getAll method. I think a new sample demonstrating that or updating an existing sample would make sense, if you want to work on something :)

@hrmtsh2
Copy link
Author

hrmtsh2 commented May 21, 2024

Sorry I was unable to find this before.
Yes, I will work on a sample demonstrating the getAll() method. My first idea was to extend the sample you've linked here to use getAll() in two ways:-

  1. To display all shortcuts in the extension popup (will be extending the sample you linked above with a couple more shortcuts and a popup)
  2. To check for unassigned shortcuts (this case could arise when two extensions attempt to register the same shortcuts) as is demonstrated in the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants