Jessie Williams
Jessie Williams

Reputation: 1

Chrome Extension button will not work on Firefox

I have a Chrome Extension button that users click on and it takes them to Amazon. The extension works fine on Google Chrome, Brave, Microsoft Edge but not Firefox.

The error Firefox gives is: The add-on downloaded from this site could not be installed because it appears to be corrupt.

I am adding the extensions in developer mode.

Manifest file

{
    "name": "My First Extension",
    "version": "1.0",
    "description": "The first extension that I made.",
    "manifest_version": 2,
    "browser_action": {
        "default_icon": "icons/icon16.png"
    },
     "icons": {
       "16": "icons/icon16.png",
    "48": "icons/icon48.png",
    "128": "icons/icon128.png"
    },
    "background": {
        "scripts": ["background.js", "eventPage.js"]
    }
}

Background file

chrome.browserAction.onClicked.addListener(function(tab) {
    chrome.tabs.create({'url': "https://www.amazon.ca/?&_encoding=UTF8&tag=capebreton-20&linkCode=ur2&linkId=fb3879953b5c459efaee9fcd9787fab9&camp=15121&creative=330641"});
});

If anyone can help me get it working for Firefox it would be greatly appreciated. Thanks

I see the one answer but I do not know what exactly to edit..

Upvotes: 0

Views: 58

Answers (1)

Sanskar Jethi
Sanskar Jethi

Reputation: 636

This won't work in firefox as you are referring to a chrome object which is unique to chrome.

I believe it's working with the newer Edge as they(Chrome and Edge) share similar engines below the hood.

What you need to do is use the browserAction API here: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction

or write a browser-centric logic to use a different api.

As the chrome api will not be available in firefox.

Upvotes: 1

Related Questions