Editing existing Firefox Add-on

北城余情 提交于 2020-01-01 16:46:35

问题


For one of the projects I'm working on, I have to use DOM Inspector to debug a Firefox extension.

The problem with DOM inspector is that it only shows you the browser below the code, there's no way to detach the browser or out the code section or browser side by side.

It didn't work for me because the plugin I was debugging had a large xul overlay, and the problematic area was at the botton, so there's no physical way to see the code for the area as well as the area itself.

So I have decided to modify DOM Inspector itself to place browser to the side of the code editor.

Here are the steps I undertook:

  1. Took the existing xpi file from the profile directory.
  2. Changed it to be a zip.
  3. Went inside and extracted inspector.jar using jar -xf <filename>
  4. Went to inspectorOverlay.xul and changed <vbox id="bxInspectorMain"> to be an hbox. (This should be enough to position those two windows horizontally.)
  5. Then I recreated jar file using jar cf.
  6. Zipped the directory making sure that the name is the same and changed extension back to xpi.

However, when I try to run it, I get the following warnings:

Warning: WARN addons.xpi: Add-on is invalid: [Exception... "Component returned failure code: 0x80520006 (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) [nsIZipReader.getInputStream]"  nsresult: "0x80520006 (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)"  location: "JS frame :: resource://gre/modules/XPIProvider.jsm :: loadManifestFromZipReader :: line 740"  data: no]
Source File: resource://gre/modules/XPIProvider.jsm
Line: 740

Warning: WARN addons.xpi: Could not uninstall invalid item from locked install location
Source File: resource://gre/modules/XPIProvider.jsm
Line: 2042

My question is - what other changes do I generally need to make for the xpi to be properly interpreted?


回答1:


Zipped the directory making sure that the name is the same and changed extension back to xpi.

I guess that you did something wrong in this step. Looking at the source code, the message comes from method updateMetadata() - Firefox noticed that the file changed and tries to read in install.rdf again. That file should be at the top level of the XPI file but in your case it cannot be found. Maybe install.rdf is no longer at the top level after you repacked the file. You can test it with the unzip command:

unzip -l inspector@mozilla.org.xpi

It should show the contents of the XPI file, including install.rdf and chrome.manifest - without any prepended directory name.




回答2:


@Luka, I guess Wladimir Palant is correct. To avoid error during the modification of source code of the existing project, I would suggest you to work in the working environment.

The suggested way to edit your source code:

  1. Install Eclipse
  2. Install Xul booster (project / docs)
  3. Extract your sour code from FF profile.
  4. Check the name of the main folder and subfolder as exactly given in you extracted .Zippy file (FF extension).
  5. Create a new project in Eclipse under XUL booster environment: please use the same name of your FF extension main folder and sub folder.
  6. Then, copy paster your extracted files to the XUL project in Eclipse.
  7. Modify your code & extract as .XPi file and Install in you FF browser.

This way you can avoid any kind of errors because everything will be classified automatically (Chrome folder, manifest, install.rdf, did dies etc).

Note: There is an advanced way of modifying source code and FF browser wil detect the modification of your source code automatically by setting the environment in your FF extension profile folder.

  1. Create a bat file and locate your project folder path and type your extension id inside the FF extension profile folder. (guide)


来源:https://stackoverflow.com/questions/7438855/editing-existing-firefox-add-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!