While working on Bookee, I discovered some strange behaviour with respect to keyboard shortcuts to activate Chrome (and likely Web) Extensions.
When the scope for a Chrome or Web Extension is set to
Global (rather than
background script (or worker script for mv3) can have
trouble detecting whether the current page is the new-tab
I wrote about the Global Shortcut earlier, which provides more context on how to allow your extension users to change a keyboard combination's scope.
I'm still working on diagnosing why the change of scope causes issues with the tab URL detection. More to come.
Turns out this was a bit of a
changing a lightbulb
experience. It took me a while to figure it all out. The
root of the issue was that the extension didn't have
access to the
urlproperty for all tabs.
The reason this problem only showed up with the global
shortcut was because I could read the
urlproperty for a focused tab. But since the global shortcut was being triggered from outside Chrome, I don't believe that the concept of a "focused tab" actually existed.
Anyway, to get around this, I needed to request the
tabspermission in my
manifest.jsonfile, and re-architect a few things around command event listeners.