I have a basic Google Chrome extension which needs to be ported to Firefox. I uploaded the .crx file to the Firefox marketplace and it got accepted but is under review rightnow. I downloaded the the generated xpi file and tried to install it locally but without any success. It tell that the plugin is invalid or corrupted.
Another method that I tried is I ported the extension using chrome-tailor and generated the xpi. I am able to install the extension in this but the content scripts are not injected and the extension doesn't work as expected.
I want to install it in Firefox and test it. I have also set xpinstall.signatures.required to false.
WebExtensions
To test WebExtension based add-ons, they are usually loaded as a "Temporary Installation in Firefox"
That MDN page describes how to temporarily install a WebExtensions (i.e. similar code to Chrome) in Firefox. The gist of it is:
Navigate to about:debugging
Click the button "Load Temporary Add-on"
Use the file selection dialog to select the manifest.json file, or packaged .xpi file for the extension.
Note on testing WebExtensions:
The WebExtensions API is still in development. For now, you are probably best off developing and testing your WebExtension add-on with Firefox Developer Edition, or Firefox Nightly. You should also make careful note of what version of Firefox is required for the functionality you desire to use. This information is contained in the "Browser compatibility" section of the MDN documentation pages.
Firefox Add-on SDK
To test Firefox Add-on SDK based ad-ons, use jpm run. You might want to take a look at this answer to "jpm run does NOT work with Firefox 48, or later"
Related
I am building a chrome extension and a JS library to allow installing this extension.
There are a couple of ways to ask a user to install the extension:
Inline installation if the site is verified and added to the extension webstore settings.
Redirect to chrome webstore otherwise.
Is there a way to check if the inline installation is supported on the site using javascript beforehand?
The only way I found so far is to trigger inline installation and then fallback to redirecting to webstore:
chrome.webstore.install(extensionUrl, successCallback, function() {
redirectToChromeWebstoreExtensionUrl();
});
This is not ideal because the redirect will be blocked by chrome since it was not triggered by a user.
What I would like to do is to first check if the site supports inline installation and then choose an appropriate method of installation.
I am trying to install an extension in Firefox 45 (same happens with Firefox 49), but Firefox does not allow me to do that, indicating that
This add-on could not be installed because it appears to be corrupt.
The way I am trying to install it is simply by dragging the .xpi file our team developed, into the Firefox window. This extension is based on MozRepl, but with some improvements.
Previously, I tried to install it but I couldn't as it was not signed (extensions in Firefox versions from 43 onwards require signing). I followed every step in order to sign it, according to this post: Signing a XPI. I am almost certain I could sign it correctly, but now the error Firefox displays is different: "This add-on could not be installed because it appears to be corrupt."
It seems that I am not creating the .xpi file correctly, but I am not sure which is the correct structure it should have. I tried different folder structures, but with no success.
Also, I checked the Browser Console to see what error is logged in, but I didn't found it really helpful. Here it is:
Here is a link to the .xpi file in case you want to check its content. Note that I tried moving the files manifest.mf, zigbert.rsa and zigbert.sf outside the META-INF folder, but it didn't work either.
Has anyone stumbled across an error like this when trying to install an add-on? Any ideas of what maybe happening?
The .xpi file must use only "deflate" compression or uncompressed
The zip implementation within Firefox only supports uncompressed files or files compressed with the "Deflate" algorithm. You will need to create the .zip archive using the compression method "Deflate" instead of the "LZMA" which you are currently using. How to do so will depend on the tools you use to create your archive.
Personally, I use a batch file/shell script to create the .xpi file as I describe in detail in my answer to "Firefox extension .xpi file structure: description, contents, creation, and installation". The basics are that I use the zip command line tool which defaults to "deflate" or uncompressed. I use the -1 option to provide the fastest compression. Firefox/Mozilla use .xpi files both to package the files, but to also increase file access speed. The important quality is not a high compression ratio, but that the files can be accessed quickly. Unless Firefox is not an WebExtension and explicitly told to unpack the add-on by the install.rdf option <em:unpack>true</em:unpack> (WebExtensions don't have install.rdf files), the add-on will be installed as the .xpi file and all access to the add-on will be as the .xpi file.
Note: Given that your extension contains .dll files, you may need to have your add-on installed unpacked by using <em:unpack>true</em:unpack>.
Wrong signing method used. It must be signed by Mozilla, not yourself.
While it is not the error you are currently seeing, as soon as you fix the problem with your .xpi format, you will encounter an issue with your extension being signed by the wrong signature. You signed your extension with your own signature. It was not signed by Mozilla. This will not work. It must be signed by Mozilla, not yourself.You mentioned that you followed the directions in the MDN page Signing an XPI. However, as is clearly stated at the top of that page, the directions on that page are outdated and no longer work. You should have followed the link in the note to the page Signing and distributing your add-on. The note at the top of the page states:
Note: These instructions are outdated. For an extension to work in Firefox it must be signed by Mozilla, not by yourself. See Signing and distributing your add-on. [Emphasis added]
There are also a variety of questions here on Stack Overflow which address the signing issue.
Like stated in other answer it happens for unverified/unsigned extension.
But sometimes for testing you might want to use unverified/unsigned extension.
As a hack/workaround to install unverified/unsigned extensions following worked for me on Firefox version 45:
Launch Firefox and hit - about:config
Search for 'xpinstall.signatures.required'
Either double click on the row OR set the value to false and close
Now retry installing the extension and it should work.
I think there is something not clearly documented, I'd like to share my experience.
Developed my extension and zipped all the files
Selected On your own for How to Distribute this Version step and uploaded .zip to AMO
Then, on the next page, I see a signed .xpi file available for download. I downloaded it and tried to install via "about:addons -> Install Add-on from file"
I get corrupt add-on error in this case
After receiving e-mail from amo-editors#mozilla.org, I went to my add-on's page and clicked on .xpi file link there and it worked!
I had this issue when I compressed the folder containing my addon rather then just the files within.
Don't Compress the Parent Folder of your Manifest
For example, on Windows CTRL+Click on your manifest and any other files or subfolders; right click and select Send to > Compressed Folder and you should be good to go.
Note: from the browser console screenshot we can tell this isn't the issue in this case, but even so this is a common problem to the This add-on could not be installed because it appears to be corrupt error.
The message because it appears to be currupt can point to various problems. You can see a more detailed error message in the Browser Console at ctrl+shift+J.
As soon as you edit anything inside an xpi file and try to add it manually to the browser, an extension ID needs to be provided inside the manifest.json if it isn't already, with applications.gecko.id or browser_specific_settings.gecko.id. For example, altering any single character in https://addons.mozilla.org/en-US/firefox/addon/quick-js-switcher/ shows Invalid XPI: Error: Cannot find id for addon in Browser Console, so you add
"applications": {
"gecko": {
"id": "some#example.com",
"strict_min_version": "1.2.3"
}
}
to the manifest.json as well and it works: But only with about:config's xpinstall.signatures.required set to false on Firefox versions that actually respect this setting, which excludes the normal release one because apparently Mozilla hates its userbase. You need FF Nightly or the like, I'm using LibreWolf.
source
This is an answer to a tangential question when the "The add-on downloaded from this site could not be installed because it appears to be corrupt" error message starts appearing when trying to install any Thunderbird add-on. There are some other sites where this tangential question has been asked but the pages got archived:
https://www.reddit.com/r/firefox/comments/7942yu/the_addon_downloaded_from_this_site_could_not_be/ (for FF)
https://support.mozilla.org/en-US/questions/1319105
http://forums.mozillazine.org/viewtopic.php?f=39&t=2739869
Since this question here still allows replies, just wanted to add that this can occasionally start happening for all add-ons if the user's local Thunderbird profile files gets corrupt in some specific way.
In such case, I recommend restarting Thunderbird in "safe mode" with all add-ons disabled via "Help" -> "Restart with Add-ons Disabled...", and then restarting back to the "regular" mode via "Help" -> "Restart with Add-ons Enabled". After that installation of add-ons may work again.
Even though this is not the answer to this specific question, hope this tip is helpful for whoever hits this specific tangential but similar situation.
I had the same problem on firefox 52, just downgrade the addon to a lower version designed for firefox 52 or less will fix this problem.
"sdk/tabs" seems impossible to use in my Firefox add-on. I wonder what's wrong. My background.js stops processing any code after this part:
var tabs = require("sdk/tabs");
E.g. if I run this code, the console will output "error1?" -- including everything above, but nothing from underneath that snippet.
console.log('error1?');
var tabs = require("sdk/tabs");
console.log('error2?');
// Listen for tab content loads.
tabs.on('ready', function(tab) {
console.log('error3?');
console.log('tab is loaded', tab.title, tab.url);
console.log('error4?');
});
console.log('error5?');
I have included "tabs" as permission in my manifest.json file. Do I need to include anything else to use "sdk/tabs"?
You mention a manifest.json file and having the tabs permission in it. manifest.json files are only used in WebExtension based add-ons. You desire to use require("sdk/tabs") which is only available in Add-on SDK extensions.
You appear to mixing APIs between WebExtensions and the Firefox Add-on SDK. These are two of the four different types of extensions for Firefox. None of the Add-on SDK APIs (neither High-Level, or Low-Level) are available from a WebExtension. Similarly, the WebExtension JavaScript APIs are not available from an Add-on SDK based extension.
Specifically, you appear to be developing a WebExtension. The sdk/tabs API is for the Add-on SDK. It will definitely not work in a WebExtension based add-on. In general, if you see require() you are almost certainly dealing with the Add-on SDK which will not work in your WebExtension add-on. Thus, you will not be able to use require("sdk/tabs") in your WebExtension based add-on.
Firefox/Mozilla has four different types of extensions:
Add-on SDK: These add-ons are described by a package.json file which is initially generated by executing jpm init. These extensions will often use require() to load either High-Level, or Low-Level APIs to interface with Firefox. Currently, these add-ons are wrapped into a bootstrapped extension when they are loaded for testing by jpm run or consolidated into an .xpi file by jpm xpi for distribution (i.e. upload to AMO/Mozilla). In other words, they are bootstrapped extensions with an SDK wrapper.
Mozilla appears to be committed to continuing to support Add-on SDK based extensions as long as the extension does not use require("chrome"), or otherwise depend on XUL, XPCOM, or XBL.
Most of the things that can be done in a bootstrapped extension can be done in an Add-on SDK based one. However, many such things bypass the SDK which forfeits a significant portion of the benefits of using the Add-on SDK.
WebExtensions: These add-ons are described by a manifest.json file. This API is similar to what is used for Google Chrome extensions. While Mozilla is claiming that this API is the future of Firefox extensions, this API is still in development. For now, you are probably best off developing and testing your WebExtension add-on with Firefox Developer Edition, or Firefox Nightly. You should also make careful note of what version of Firefox is required for the functionality you desire to use. This information is contained in the "Browser compatibility" section of the MDN documentation pages.
WebExtensions use a significantly different API. There is, intentionally, no ability to use the interfaces provided by any of the other add-on types.
Bootstrapped: These extensions are also commonly called "restartless" because they were the first type of Mozilla extension which did not require the application to be restarted in order to load/unload the add-on. However, restartless is a descriptor of how they function. Using "restartless" as the name for this type of add-on is confusing because both Add-on SDK and WebExtension add-ons also do not require the application to be restarted upon load or unload of the add-on. For that reason, there is a tendency to no longer use "restartless" as the name for this type of add-on.
These add-ons have a JavaScript file called bootstrap.js which must contain entry points (functions) which are called for add-on startup(), shutdown(), install() and uninstall().
These add-ons contain a install.rdf that describes the add-on.
They usually, but not always, also contain a chrome.manifest file that describes how the files and directories in the extension relate to the Mozilla application (e.g. Firefox).
Most, but not all, of the things that can be done in overlay/XUL/Legacy extensions can be accomplished in bootstrapped add-ons. Anything that can be done in the Add-on SDK can be done in a bootstrapped extension (Add-on SDK extensions are bootstrapped add-ons with some JavaScript based API layers).
Mozilla has stated that they plan to deprecate "add-ons that depend on XUL, XPCOM, and XBL." While not all bootstrapped add-ons depend on these technologies, there is a tendency for for bootstrapped add-ons to operate at a lower level than Add-on SDK and WebExtension add-ons. Thus, they are more likely to use these technologies. While there are some that are saying that all bootstrapped add-ons are planned to be deprecated, it is not clear that is the case. After all, Add-on SDK extensions are not being deprecated (unless they use require("chrome"), or otherwise depend on XUL, XPCOM, or XBL) and all Add-on SDK extensions are bootstrapped extensions, just with an SDK wrapper.
Overlay/XUL/Legacy: These add-ons contain a install.rdf that describes the add-on and a chrome.manifest file to describe how the add-on's files relate to (e.g. overlay) the application's files. How the add-on functions with the application is completely dependent on the relationships described in the chrome.manifest file. The only exceptions to this are a few things like icons for the extension and the file describing the extension's options which are indicated in the install.rdf file. These extensions interact with the application (e.g. Firefox) at a very low level. This tends to make them more likely to break when changes are made to the application.
All Overlay/XUL/Legacy extensions are planned to be deprecated.
I would like to inject JavaScript into a website on a mobile browser (in this case on android). However, most mobile browsers do not seem to support any kind of plug-ins (except for Firefox, correct me if I am wrong).
Firefox support for mobile plugin development seems to be minimal too, for example one can not install xpi-files by downloading them (I have yet to find out how one can install a plugin that is not hosted on the add-ons for android site)
Why not use existing solutions?
The best way to inject javscript would be Greasemonkey but this is not supported on mobile. Scriptish supposedly is but I could not install it on any device. There are android browsers specifically written to support Greasemonkey scripts (Fat Ape or Tampermonkey or OilCan) but these are not used by many and while they enable JavaScript injection the lack in their support for other browser-features.
What exactly is my question?
My experience in Firefox-Plugin development is minimal so I would like to know: Is there something that would prevent something like this to run on FF-Mobile? Could it be done with other browsers too? I don't actually need the full power of Greasemonkey, injecting the same few lines into any website would probably do.
Update 2
This again needs updating!
The new Firefox (current 95.2) no longer supports this method! But the old version still does! You will have to DL an old version (let's say 68.7). You can get it on ApkMirror. Then to install Greasmonkey either google it and choose the Mozilla page or just visit this link. On that page choose to download the file. When the XPI file will be downloaded it will automatically request to install it and that's it. You now have Greasemonkey installed on your Android device!
Be advised that this is an old unsupported Firefox version full of security holes!
Update
This needed updating!
The new Firefox now has full support for Greasemonkey add-on!
Instructions:
Find and install Firefox on the play store.
Run it and from the menu choose Add-ons and install your favorite add-ons like the ad blocker uBlock origin. Use the search and input Greasemonkey and install it.
Profit! :)
Old
If you want full Greasemonkey with even cross domain / cross site
GM_xmlhttpRequest support then your only option right now is: Opera
Mobile Labs (with Extensions) (link to APK is on that site).
Run Opera Mobile Labs app and visit Violent Monkey's extension
site and install the 1.5.1.1 (OEX version) by clicking on "Add to
Opera" and then choose "OK" (maybe you'll have to restart Opera
Mobile for the extension to work.).
To install an userscript you just need to load it in the browser by
visiting the user.js URL location. If you have userscripts on your
SD card, you can load them thru entering "file://" into the address
bar and navigate to your user.js files and then choose "OK".
If you have a bunch of normal scripts (no GM_ functions) then you
could also use this instructions (it's faster!):
Save your user.js scripts in a folder on your SD card (eg. "/sdcard/js").
Run Opera Mobile app and enter "opera:config" into the address bar and then in the "Quick find" input enter "javascript". Go
down and under "User Prefs" tick the following: "Always Load User
Javascript" and "User Javascript". Under "User Javascript File"
enter the path to the folder with your user.js files (eg.
"/sdcard/js").
At the end don't forget to tap "Save" otherwise your setting will not be saved! Restart Opera!
If you don't want to download the APK file then this second method
also works with Opera Mobile Classic. You can find the app in the
Play Store.
If you can install Google Chrome (Android > 4.0) on your mobile phone you can do remote debugging.
Overview of Google Chrome for mobiles :https://developers.google.com/chrome/mobile/docs/overview
Overview of Remote Debugging: https://developers.google.com/chrome-developer-tools/docs/remote-debugging
Another option for running Userscripts on mobile devices is the Tampermonkey userscript manager.
There are Tampermonkey add-ons for both the Dolphin and UC Android browsers.
Tampermonkey add-on for the Dolphin Web Browser:
https://play.google.com/store/apps/details?id=net.tampermonkey.dolphin
Tampermonkey add-on for the UC Web Browser
https://play.google.com/store/apps/details?id=net.tampermonkey.uc
To use them you first need to have the respective browser installed.
I'm developing a JavaScript extension for Chromium and my current workflow is:
Edit file
Uninstall old file
Install new file
Test file
Is there a quicker way of doing this?
I'm using chromium-browser_5.0.375.125 in Ubuntu 10.04.
Load your extension into Chromium
Find your extension's ID:
Go to the extensions page chrome://extensions/
Click + Developer Mode
Scroll down to your extension and look at the ID: field
Open ~/.config/chromium/Default/Extensions/ID/VERSION/script.js in a text editor
Now simply edit, save, and test
For a pure JavaScript extension the version number should be 1.0.