I have a Firefox add-on which is an overlay based extension working in Firefox version up to 31. But its not working in version 32 and above. I normally use the Userscript Compiler tool to build my extension. I don't see anything(errors/outputs) in the console from my extension.
Though when i run my script using the Greasemonkey plugin its working fine. The problem is when running the extension after building it as an XPI file.
Below is my extension structure:
myextension
|-->skin
|-->classic
|-->content
|-->myscript.user.js
|-->myscriptPrefman.js
|-->myscriptScript-compiler.js
|-->myscriptXmlhttprequester.js
|-->script-compiler-overlay.xul
|-->chrome
|-->install.rdf
|-->icon.png
|-->chrome.manifest
Below are the install.rdf
file contents:
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>{9ef9b86c-03da-4e10-9552-e97a6d258af5}</em:id>
<em:name>Sample Extension</em:name>
<em:version>2.6</em:version>
<em:description>A sample extension - Firefox</em:description>
<em:creator>Mozdev</em:creator>
<em:contributor>Greasemonkey Compiler by Anthony Lieuallen;</em:contributor>
<em:contributor>http://arantius.com/</em:contributor>
<em:homepageURL>www.example.com</em:homepageURL>
<em:targetApplication><Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>2.0</em:minVersion>
<em:maxVersion>35.*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>
chrome.manifest
contents:
content myextension content/
overlay chrome://browser/content/browser.xul chrome://myextension/content/script-compiler-overlay.xul
skin myextension classic/1.0 skin/classic/
Do I need to change anything in the extension or convert it to a Bootstrap extension or use the Add-on SDK to build the XPI file?
I have followed the Add-on SDK method suggested by Wladimir and created an XPI installer file. But the userscripts are not running inside the page.
The code still runs from the Greasemonkey add-on.
This is the Greasemonkey script that runs fine in Greasemonkey, but not when made into an extension via neither the compiler nor the SDK.
I followed the steps to install the Add-on SDK in my local machine. I used the cfx
command to build the XPI file. I install this in Firefox latest version(ver.33.0.2) and visit openuserjs.org I can't see anything. Why is that?
I have replicated the code just by using Firefox Request Api for GM_XmlhttpRequest and local storage for storing information locally. And make the script communicate with the main.js using Message Passing which is the backbone of the Restartless Firefox Addon SDK Api's.
var data = require("self").data;
var pageMod = require("page-mod");
pageMod.PageMod({
include: "*.example.com", //mywebsite url
contentScriptWhen: 'start',
contentScriptFile: data.url("contentScript.js")
});
contentScriptFile is the place you want to write your userscripts and communicate with the main.js using port messaging in the latest Firefox AddonSDK API's.
I used Request API for getting information from the server instead of using the unsupported GM_xmlhttpRequest.
var Request = require("sdk/request").Request;
var userDetails = Request({
url: "http://example.com/user/1",
onComplete: function (response) {
var res = response.json[0];
}
});
And now the extension is restartless and totally rewritten using the High and Low level api's in the Firefox Documentation. Hope future browser changes will be using these api's and support the extension as longer period of time.