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

[Enhancement] Firefox support #12

Open
RemiRigal opened this issue Apr 15, 2022 · 13 comments
Open

[Enhancement] Firefox support #12

RemiRigal opened this issue Apr 15, 2022 · 13 comments
Labels
enhancement New feature or request

Comments

@RemiRigal
Copy link
Owner

RemiRigal commented Apr 15, 2022

Despite an official announcement from Mozilla a year ago, we don't have any information about Manifest v3 support.
Adding Firefox support for Overseerr Assistant is then a matter of either:

  • Waiting for Manifest v3 support in Firefox
  • Add Manifest v2 support in the extension

Adding Manifest v2 support to the extension implies a lot of refactoring as there is a lot of breaking changes between the two versions. It would also be harder to maintain.

@iEusKid
Copy link

iEusKid commented Mar 12, 2023

now that Firefox support Manifest v3,
are you gonna add the extension? it is pretty cool but i don't use chrome and many others, PLS.

@Gwouigwoui
Copy link

Any news of a possible Firefox version? The CRX file passes the test on https://www.extensiontest.com, with a few errors.
Merci !

@CaphalorAlb
Copy link

hey, any chance you guys have some spare time to check this out again?

I know it means some extra work, but it would be great to have Firefox support :)

@JoshTheBlack
Copy link

JoshTheBlack commented Aug 30, 2023

I see this was added to the FF store.
I'm having trouble with it though.
It shows logged in on the settings page, but on trakt.tv the button says "Media not found" and links to my Overseer url.
in about:debugging#/runtime/this-firefox it has a warning: "Reading manifest: Warning processing options_page: An unexpected property was found in the WebExtension manifest."
When inspecting, I get a source map error :

Source map error: Error: NetworkError when attempting to fetch resource.
Resource URL: moz-extension://cbac435b-35f3-496c-9e36-0f49fc1e717f/css/bootstrap.min.css
Source Map URL: bootstrap.min.css.map

and an uncaught reference error:

Uncaught ReferenceError: importScripts is not defined
    <anonymous> moz-extension://cbac435b-35f3-496c-9e36-0f49fc1e717f/background.js:1
background.js:1:1

@NLZ
Copy link

NLZ commented Aug 30, 2023

The Firefox version if others want to try it:
https://addons.mozilla.org/en-US/firefox/addon/overseerr-assistant/

Sadly I'm getting CORS errors:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:5055/api/v1/status. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 405.

Navigating to http://127.0.0.1:5055/api/v1/status returns {"version":"1.33.2","commitTag":"1.33.2","updateAvailable":false,"commitsBehind":0,"restartRequired":false}, so that works.
Maybe it has trouble with the localhost itself?

I cannot try it with hostname instead because it doesn't have https and fails:

Content-Security-Policy: Upgrading insecure request ‘http://chaos.nlan:5055/api/v1/status’ to use ‘https’
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://chaos.nlan:5055/api/v1/auth/me. (Reason: CORS request did not succeed). Status code: (null).

@JoshTheBlack do you have https working?

@RemiRigal
Copy link
Owner Author

RemiRigal commented Aug 30, 2023

Yes, I uploaded the extension to the Firefox Addon store but as mentioned here Firefox is still not supporting service workers. Here is the related bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1573659.
This is a huge part of the Manifest V3 implementation, and Overseerr Assistant heavily relies on it.

Since the Firefox version has been requested several times now, I will try to find some time to work on it in the next weeks, I will keep you updated.

@JoshTheBlack
Copy link

The Firefox version if others want to try it: https://addons.mozilla.org/en-US/firefox/addon/overseerr-assistant/

Sadly I'm getting CORS errors:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:5055/api/v1/status. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 405.

Navigating to http://127.0.0.1:5055/api/v1/status returns {"version":"1.33.2","commitTag":"1.33.2","updateAvailable":false,"commitsBehind":0,"restartRequired":false}, so that works. Maybe it has trouble with the localhost itself?

I cannot try it with hostname instead because it doesn't have https and fails:

Content-Security-Policy: Upgrading insecure request ‘http://chaos.nlan:5055/api/v1/status’ to use ‘https’
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://chaos.nlan:5055/api/v1/auth/me. (Reason: CORS request did not succeed). Status code: (null).

@JoshTheBlack do you have https working?

Yes. My instance is docker hosted and proxied through SSL with traefik, hosted on a publicly accessible subdomain. This extension works perfectly in Chrome with the same settings.

@RemiRigal I just happened to see it in the store and assumed it would be working now. I'll keep an eye out for updates. Thanks!

@nononolimits
Copy link

Any status update on this?

@kaperala
Copy link

Any progress on this @RemiRigal?

@AdmiralAwesome
Copy link

Hey, any news? Since Chrome is making a lot of stupid changes, many people moved back/to Firefox. It would be awesome to have this extension working as well.

@VozDeOuro
Copy link

hello, any chance you guys have some spare time to check this out again?

@thoughtsunificator
Copy link

thoughtsunificator commented May 15, 2024

Edit: Firefox support is now official, see #12 (comment).


Here's a Firefox build in the meantime: https://0x0.st/XKhl.0.xpi

Tested on Firefox 125.0

Make sure :

  • To grant site permissions to the add-on
  • CORS is set up properly

Diff :

diff --git a/background.js b/background.js
index 14f157a..f7f3a96 100644
--- a/background.js
+++ b/background.js
@@ -1,4 +1,57 @@
-importScripts('js/storage.js');
+let serverAPIKey, serverPort, serverIp, serverProtocol, serverPath, origin, userId, version;
+
+
+function pullStoredData(callback) {
+    chrome.storage.sync.get(['serverAPIKey', 'serverIp', 'serverPort', 'serverProtocol', 'serverPath', 'userId', 'overseerrVersion'], function(data) {
+        serverAPIKey = data.serverAPIKey || '';
+        serverIp = data.serverIp || '172.0.0.1';
+        serverPort = data.serverPort || 8001;
+        serverProtocol = data.serverProtocol || 'http';
+        serverPath = data.serverPath || '/'
+        origin = `${serverProtocol}://${serverIp}:${serverPort}${serverPath}`;
+        if (origin.endsWith('/')) {
+            origin = origin.slice(0, origin.length - 1);
+        }
+        userId = data.userId || undefined;
+        overseerrVersion = data.overseerrVersion || undefined;
+        if (callback) callback(data);
+    });
+}
+
+function isLoggedIn(callback) {
+    getLoggedUser(function(userSuccess, userErrorMsg, userResponse) {
+        getOverseerrVersion(function(versionSuccess, versionErrorMsg, versionResponse) {
+            userId = userSuccess && versionSuccess ? userResponse.id : null;
+            version = userSuccess && versionSuccess ? versionResponse.version : null;
+            chrome.storage.sync.set({
+                userId: userId,
+                overseerrVersion: version
+            });
+            if (callback) callback(userSuccess && versionSuccess, userId);
+        });
+    });
+}
+
+function setOrigin(apiKey, ip, port, protocol, path, callback) {
+    serverAPIKey = apiKey;
+    serverIp = ip;
+    serverPort = port;
+    serverProtocol = protocol;
+    serverPath = path;
+    origin = `${serverProtocol}://${serverIp}:${serverPort}${serverPath}`;
+    if (origin.endsWith('/')) {
+        origin = origin.slice(0, origin.length - 1);
+    }
+    chrome.storage.sync.set({
+        serverAPIKey: serverAPIKey,
+        serverIp: serverIp,
+        serverPort: serverPort,
+        serverProtocol: serverProtocol,
+        serverPath: serverPath
+    }, function () {
+        if (callback) callback();
+    });
+}
 
 
 function encodeURIComponentSafe(value) {
diff --git a/manifest.json b/manifest.json
index dff57de..8743758 100644
--- a/manifest.json
+++ b/manifest.json
@@ -66,11 +66,17 @@
   }],
   "options_page": "options.html",
   "background": {
-    "service_worker": "background.js"
+    "scripts": ["background.js"]
   },
   "web_accessible_resources": [{
     "resources": ["images/icon.png"],
     "matches": ["<all_urls>"]
   }],
+	"browser_specific_settings": {
+		"gecko": {
+			"id": "overseerrassistant@thoughtsunificator.me",
+			"strict_min_version": "100.0"
+		}
+	},
   "manifest_version": 3
 }

@RemiRigal
Copy link
Owner Author

Better late than never, Firefox support is now official !

You can install the extension from the store: https://addons.mozilla.org/en-US/firefox/addon/overseerr-assistant

As permissions for websites are opt-in for users, you will have to go to the extensions settings and enable either Access your data for all websites or enable all the desired websites like so:
image

Let me know if you experience any unexpected behaviors. Enjoy !

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

No branches or pull requests