Skip to content

New Firefox release #46

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

Open
pgrosslicht opened this issue Apr 6, 2025 · 6 comments · May be fixed by #48
Open

New Firefox release #46

pgrosslicht opened this issue Apr 6, 2025 · 6 comments · May be fixed by #48

Comments

@pgrosslicht
Copy link

Hello,

the linked Firefox extension (https://addons.mozilla.org/en-US/firefox/addon/archivebox-exporter/) has last been updated 3 years ago, is there any chance to get the new version packaged for Firefox as well?

I've quickly tried to run it in Firefox, but it seems like there could be some code changes necessary as it didn't submit the urls to ArchiveBox, but failed here.

Thank you!

@pirate
Copy link
Member

pirate commented Apr 7, 2025

yes it's planned but looking for help with testing on firefox

@pgrosslicht
Copy link
Author

I can help with that!

@pirate
Copy link
Member

pirate commented Apr 15, 2025

@pgrosslicht that would be awesome. If you can install it as an unpacked extension and report any bugs you encounter here that would be helpful. I would happily review any PRs for firefox fixes that people want to submit.

@pgrosslicht
Copy link
Author

Ok, I've tried installing it, here's the issues I ran into:

  1. Firefox extensions require an Add-on ID

    Solution

    Extend manifest.json with the Add-on ID:

    --- a/manifest.json
    +++ b/manifest.json
    @@ -50,5 +50,10 @@
             "mac": "Command+Shift+X"
           }
         }
    +  },
    +  "browser_specific_settings": {
    +    "gecko": {
    +      "id": "..."
    +    }
       }
     }

  2. "background.service_worker is currently disabled. Add background.scripts."

    Solution

    Extend manifest.json with the background scripts:

    --- a/manifest.json
    +++ b/manifest.json
    @@ -35,12 +35,13 @@
       },
       "options_page": "options.html",
       "background": {
    +    "scripts": ["background.js"],
         "service_worker": "background.js",
         "type": "module"

With these changes I can now at least install the extension in Firefox. I can see the icon in my toolbar and preferences are looking good too. However, when clicking the icon (after configuring my server), the popup shows just for an instant before closing again. The console logs TypeError: can't access property "ok", response is undefined: popup.js:45:13

This seems to be because Firefox' sendMessage is used a bit differently, so I changed it like this:

--- a/popup.js
+++ b/popup.js
@@ -37,16 +37,9 @@ async function sendToArchiveBox(url, tags) {
       tags: tags.join(','),
     });
 
-    const addResponse = await new Promise((resolve, reject) => {
-      chrome.runtime.sendMessage({
-        type: 'archivebox_add',
-        body: addCommandArgs
-      }, (response) => {
-        if (!response.ok) {
-          reject(`${response.errorMessage}`);
-        }
-        resolve(response);
-      });
+    const addResponse = await chrome.runtime.sendMessage({
+      type: 'archivebox_add',
+      body: addCommandArgs
     })
 
     ok = true;

This seems to make it send the archiving API call to ArchiveBox at least, but the popup still closes instantly. Since this is good enough for me, this is about as far as I went.
Hope this helps!

@pirate
Copy link
Member

pirate commented Apr 16, 2025

A PR for those fixes would be awesome @pgrosslicht! If you don't have time no worries, @benmuth can add these patches in our next round of fixes after #47 is merged.

@pgrosslicht
Copy link
Author

I'm a bit hesitant providing a PR because as I don't use Chrome I have no idea if any of my changes break anything for Chrome 🙈

@benmuth benmuth linked a pull request May 1, 2025 that will close this issue
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 a pull request may close this issue.

2 participants