Skip to content

Conversation

@andyross
Copy link

@andyross andyross commented Jul 1, 2025

Derived from original work by @gutschke on github (see #147).

Use new storage API. Fix up situation where the callbacks can be invoked in an environment where KeyboardEvent isn't defined (and it can't detect the "location" correctly).

@andyross
Copy link
Author

andyross commented Jul 1, 2025

Attempt at a cleanup and submission of the manifest v3 fixups discussed in #147

Note that I'm very much not a chrome extension or even JavaScript person. Review carefully.

Derived from original work by @gutschke on github (see google#147).

Use new storage API.  Fix up situation where the callbacks can be
invoked in an environment where KeyboardEvent isn't defined (and it
can't detect the "location" correctly).
Copy link
Collaborator

@jpalmer jpalmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sending this through, just a few small comments


if (key == 'Enter'
&& location == KeyboardEvent.DOM_KEY_LOCATION_NUMPAD) {
&& location && location == KeyboardEvent.DOM_KEY_LOCATION_NUMPAD) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't need location && location == something

location == something should be fine

(and === would probably be better)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This turned out to be a special case of the KeyboardEvent-missing problem, testing location was a proxy.


let location = keyData.location;
if (location === undefined) {
if (location === undefined && typeof KeyboardEvent !== 'undefined') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This extra check seems odd to me - could you add a comment to explain why we need it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's happening is that "KeyboardEvent" is an undefined symbol in some contexts where this gets run. I don't remotely understand the service worker architecture to understand why that might be, but it seems not to correspond to actual user key events.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no DOM in the serviceworker environment which might explain why there is no keyboardevent - but in that case I think we can assume that keyboardevent would always be null?

setComposeFile(defaultComposeFile);
} else {
console.log('Loaded compose file from local storage (%d characters).',
lengthInCodepoints(content));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this content be val?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. And indeed the custom compose file code path (which I didn't try)0 isn't working, for this bug for sure but there are other exceptions I need to look at. Update coming, though ideally someone with a better idea of this stuff might want to try too.

@jpalmer
Copy link
Collaborator

jpalmer commented Jul 1, 2025

Also, just checking, but did you test this locally to see if it all works as expected?

@andyross
Copy link
Author

andyross commented Jul 2, 2025

Indeed, this isn't ready. The code in options.js expects to use a background page for storing the text of the custom .XCompose file (I'm not entirely sure why? It's just for the options UI and ephemeral, right?), and background pages don't work anymore as I'm gathering. There's some support in there for using the option page DOM instead, but turning that on doesn't work and I get oddball serialization output instead of the file contents.

This may need someone with more web-fu that I have. I do firmware. But I'll continue to work on it time available, as I really genuinely miss this extension badly.

@dnzgr
Copy link

dnzgr commented Jul 16, 2025

Thank you for working on this, I really miss this working properly also. If I had the skills I would jump in

@colmbuckley
Copy link
Collaborator

colmbuckley commented Jul 16, 2025

Note: if you enable chrome://flags/#allow-legacy-mv2-extensions, and enable developer mode on chrome://extensions you can then still load the ComposeKey manifest as an unpacked extension.

Thank you for working on this, I really miss this working properly also. If I had the skills I would jump in

@dnzgr
Copy link

dnzgr commented Jul 16, 2025 via email

@bboissin
Copy link

bboissin commented Dec 19, 2025

Is chrome://flags/#allow-legacy-mv2-extensions still supposed to work? (I can't find it).

Otherwise does this PR actually work (even if not all functionality is present), should I give it a try?

ok, replying to self, it does work but changing settings doesn't.

I've hardcoded my preferred composekey in the extension and it works (search for AltRight in background.js)

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

Successfully merging this pull request may close these issues.

5 participants