Hello! I fiddled with the published Chrome .crx and got it working very easily with Firefox - I only had to make two very minor changes to the code, and tweak the manifest very slightly. After that, everything worked immediately.
Given that it all seems to work with a couple of trivial changes, I’d like to formally request a release of the extension for us Firefox users! I would find it very useful rather than having to maintain my own hacky fork that doesn’t get updates and so on.
Is this something that is already on the roadmap?
Thanks much, and thanks for Readlang!
ETA: I tried just using the bookmarklet, but due to CSP issues, it failed almost everywhere I tried, so I gave up on it in favor of my experiments with getting the actual extension to work on Firefox.
Thanks for trying this and for letting me know. I wasn’t aware that it would be so easy to port it. I tried creating a Firefox add-on back in 2013 and it used a completely different API to Chrome extensions, and Mozilla ended up rejecting it from their add-on repo because it ran code fetched from my server.
Right now Firefox only accounts for 3% of visitors to the webapp, so although it would be cool, creating a Firefox extension isn’t on my roadmap at the moment. This could change in future though.
Thanks much for the response. Yeah, I was also surprised by how easy it was to get it working on Firefox. It is neat that the APIs are quasi-identical nowadays.
If it changes your opinion at all: I’d probably be happy to volunteer to maintain/comaintain the firefox extension (and submit PRs to you, to keep it working in the odd event it breaks). I’ve never submitted an extension to Mozilla before, but I’d be willing to figure it out, and then just update it when you cut releases of the Chrome extension. That way, at least an extension would exist for Firefox even if it lags behind slightly/is considered best-effort or unofficial.
No worries if not, just throwing the offer out there. For now I’ll keep using my hacky version and hoping it keeps working, because I do find it super useful.
@Rick_E thanks very much for your offer and sorry for not responding sooner. I too would be interested to see what was required to make this work. If there’s a way to use the same code base (perhaps with a few conditionals sprinkled in) and get it working on both Firefox and Chrome then I’d be open to publishing a Firefox extension. If you could share either a list of changes or just your whole Readlang extension bundle for Firefox either here or directly with me steve@readlang.com that would be appreciated!
Two tiny changes in manifest.json (I believe you can probably just leave service_worker instead of replacing it. The other change is just to add an id.)
And then two really small code changes, because for some reason, firefox’s JS engine doesn’t seem to like if you assign window.addEventListener to a variable and call it. Here I just commented out the old code, but I think it would be pretty easy to find a solution that works for both browsers.
@Johannes Download the .crx for the chrome extension, unzip it, apply the above patch, then in firefox go to about:debugging > This Firefox > go down to Temporary Extensions, and load the manifest file.
(The unfortunate part of doing it this way is you’ll have to re-load it every time you restart firefox, but for me that is rare anyway).
nice, thank you. It works just fine (apart from 2 small warnings because of invalid fields in the manifest.)
@Steve it would be really nice if you could publish that officially
I just tested it, the only problem with the event listener is that it needs the correct “this” binding in firefox. For chrome it does not seem to matte.
So if you replace the eventListener("message", (event) =>…) calls
with eventListener.call(window, "message", (event) =>…) calls, it should work with the same code base, even when assigning the addEventListener to a variable.
Not sure though when the attachEvent code path would trigger and if that would also work the same or if that code path would even be relevant for FF.
(edit: as far as I understand it after a bit searching, the attachEvent is anyway only needed for IE )
Apparently it hasn’t been subjected to human review so there’s always the chance they may remove it, but please give it a try and let me know if you notice any problems.