如何创建快速最小的 Firefox 扩展?

发布于 2024-07-07 21:59:30 字数 35 浏览 10 评论 0原文

开始开发 Firefox 扩展所需的最低基本设置是什么?

What the minimum basic setup required to begin developing a Firefox extension?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

╰ゝ天使的微笑 2024-07-14 21:59:30

注意事项:为了防止扰乱您的默认 Firefox 体验,请在新创建的一次性测试帐户上尝试以下提示。

第 1 步:创建一个新的 Firefox 配置文件。 为此,您需要通过命令行选项调用配置文件管理器:

firefox.exe -profilemanager

单击配置文件管理器的“创建配置文件”按钮,这将调用一个向导。 为配置文件命名。 使用“选择文件夹”按钮并将配置文件保存在适当命名的文件夹中。 我们将在这个文件夹中创建快速而肮脏的 Firefox 扩展。

步骤 2:将目录更改为步骤 1 中创建的配置文件文件夹中的“extensions”文件夹。现在我们需要为 Firefox 扩展指定一个全局唯一的名称。 类似于电子邮件的名称就足够了。 例如,[电子邮件受保护]为扩展名起一个足够好的名字。 在“扩展”文件夹下,创建一个文件夹,其名称为刚刚选择的唯一名称。

步骤 3:创建文件 chrome.manifest 和 install.rdf。 您可以将示例复制粘贴到此处,并适当更改名称和描述。

chrome.manifest:

content 1mffext chrome/

和 install.rdf:

<?xml version="1.0"?>
<RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#"
         xmlns:NC="http://home.netscape.com/NC-rdf#"
         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <RDF:Description RDF:about="rdf:#$Fsv+Z3"
                   em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
                   em:minVersion="2.0"
                   em:maxVersion="3.0.*" />
  <RDF:Description RDF:about="urn:mozilla:install-manifest"
                   em:id="[email protected]"
                   em:type="2"
                   em:name="[email protected]"
                   em:version="0.0.1"
                   em:description="One Minute FireFox extension"
                   em:creator="labsji "
                   em:homepageURL="http://labsji.wordpress.com">
    <em:contributor>Venkat83</em:contributor>
    <em:targetApplication RDF:resource="rdf:#$Fsv+Z3"/>
  </RDF:Description>

步骤 4 创建名为 chrome 的文件夹,并在该文件夹中创建名为 test.txt 的文本文件。 文件夹中的文件可以通过 chrome url 访问,例如 chrome://1mffext/content/test.txt

现在,最低限度的扩展已准备就绪。 常规 html/javascript 文件可用于创建所需的功能。

测试扩展:
调用 Firefox 以使用上面创建的配置文件。

firefox.exe -profile <path of the newly created profile> -no-remote

我创建了一个 googlecode 项目来共享按照上述步骤创建的结果代码。 代码和运行脚本可在 Just a Minute Firefox Extension

Sim 上获取-OnDemand- 个人虚拟世界即服务的启动器应用程序是一个打包的应用程序示例,使用此方法进行分发。

Precaution: In order to prevent messing with your default Firefox experience, try the tip below on a newly created disposable test account.

Step 1: Create a new Firefox profile. For this you need to invoke the Profile Manager via command line option:

firefox.exe -profilemanager

Click on the 'Create Profile' button of the Profile Manager, which will invoke a wizard. Give the profile a name. Use the 'Choose Folder' button and save the profile in a appropriately named folder. This folder is where we are going to create our quick and dirty Firefox extension.

Step 2: Change directory to 'extensions' folder within the profile folder created in Step 1. Now we need to give the Firefox extension a globally unique name. Email-like names are good enough for that. For example, [email protected] will be good enough name for the extension. Under the 'extensions' folder, create a folder with its name as the just chosen unique name.

Step 3: Create files chrome.manifest and install.rdf. You can copy paste the sample here with the names, description altered appropriately.

chrome.manifest:

content 1mffext chrome/

and install.rdf:

<?xml version="1.0"?>
<RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#"
         xmlns:NC="http://home.netscape.com/NC-rdf#"
         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <RDF:Description RDF:about="rdf:#$Fsv+Z3"
                   em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
                   em:minVersion="2.0"
                   em:maxVersion="3.0.*" />
  <RDF:Description RDF:about="urn:mozilla:install-manifest"
                   em:id="[email protected]"
                   em:type="2"
                   em:name="[email protected]"
                   em:version="0.0.1"
                   em:description="One Minute FireFox extension"
                   em:creator="labsji "
                   em:homepageURL="http://labsji.wordpress.com">
    <em:contributor>Venkat83</em:contributor>
    <em:targetApplication RDF:resource="rdf:#$Fsv+Z3"/>
  </RDF:Description>

Step 4 Create folder called chrome and create a text file called test.txt within the folder. files in the folder will be accessible via chrome url like chrome://1mffext/content/test.txt

Now the bare minimum extension is ready. Regular html/javascript files can be used to create the functionality desired.

Testing the Extension:
Invoke firefox to use the profile created above.

firefox.exe -profile <path of the newly created profile> -no-remote

I have created a googlecode project to share the resultant code created following the steps above. The code along with run scripts are available at Just a Minute Firefox Extension

Sim-OnDemand- personal virtual world as a Service's launcher application is an example of an application packaged and distributed using this method.

幸福还没到 2024-07-14 21:59:30

第 1 步:使用 Add-on Builder 生成所有必需的文件。

步骤2:将下载的文件解压到您的开发区域。

步骤 3:在您的个人资料扩展文件夹中创建一个文本文件,根据下载的 install.rdf 文件中的 em:id 命名,将解压文件的完整路径放入其中,然后重新启动 Firefox(如有必要,请删除该文本文件以卸载) 。

Step 1: Use the Add-on Builder to generate all the necessary files.

Step 2: Extract the downloaded files into your development area.

Step 3: Create a text file in your profile's extensions folder named according to the em:id in the downloaded install.rdf file, put the full path to your extracted files in it then restart Firefox (delete the text file to uninstall if necesary).

笑梦风尘 2024-07-14 21:59:30

要使用不同的配置文件启动另一个 Firefox 实例,您可以使用以下命令:

firefox -P My_test_profile -no-remote

这样您就可以运行 2 个不同的 Firefox,并使用其中一个来测试扩展,而不会干扰您经常使用的那个。

To start another instance of firefox with a different profile you can use the following command:

firefox -P My_test_profile -no-remote

This way you can have 2 different firefox running and use one for testing extensions without messing with the one you use regularly.

吃兔兔 2024-07-14 21:59:30

有趣的信息。
现在要回答这个问题,我会说:创建一个 Greasemonkey 脚本(或 Chickenfoot、iMacros 等)。
可能会受到更多限制(例如更改 FF UI),但适合大多数需求。

Interesting information.
Now to answer the question, I would say: create a Greasemonkey script (or Chickenfoot, or iMacros, etc.).
Might be more limited (in changing FF UI for example) but good for most needs.

怀里藏娇 2024-07-14 21:59:30

以下是有人想要创建一个最小的 Firefox 扩展的原因。

  1. 当您希望创建本地计算机(磁盘)驻留的基于浏览器的应用程序时,如果应用程序被构造为扩展,则可以与文件系统进行交互以进行读写。
  2. 快速原型设计,无需担心 XmlHttpRequest 跨域问题。 当您作为普通应用程序运行时,每当尝试 XmlHttpRequest 时,用户都会遇到弹出窗口的麻烦。
  3. 很多时候,安装扩展会引起很多焦虑,“这会扰乱我的其他自定义设置吗?”。 正在进行的扩展可以与配置文件一起分发,以便用户可以预览、测试它。 不用担心会破坏默认的 Firefox 浏览体验。

Here are the reasons why someone would want to create a minimal firefox extension.

  1. When you wish to create a local computer( disk) resident browser based application, interacting with the file system for reading and writing is possible if the application is structured as an extension.
  2. Quick prototyping without worrying about XmlHttpRequest cross domain issues. When you run as plain application, user is hassled with a pop-up whenever XmlHttpRequest is attempted.
  3. Many a times, installing an extension causes a lot of angst in terms of 'Will this mess up with my other customizations?'. A work in progress extension can be distributed along with a profile so that the user can preview, test it. Without worrying about messing with the default firefox browsing experience.
情仇皆在手 2024-07-14 21:59:30

附加 SDK 使简单的附加开发变得更加容易。
https://developer.mozilla.org/en-US/Add-ons/SDK

适用于 Mac/Linux 的步骤:

The Add-On SDK makes simple add-on development easier.
https://developer.mozilla.org/en-US/Add-ons/SDK

Steps for Mac/Linux:

猥琐帝 2024-07-14 21:59:30

我建议在 Firefox 的便携版上进行测试。

I suggest testing on the Portable edition of Firefox.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文