Firefox 扩展文件结构

发布于 2024-12-25 03:44:35 字数 892 浏览 0 评论 0原文

我正在努力更新 Greasemonkey 编译器来打包 Firefox 扩展。我认为原始版本适用于 Firefox 版本 3.6 和 Greasemonkey 版本 0.7.20070607.0,源代码位于 GitHub 此处。我将在此处进行更新。

我试图弄清楚 Firefox 9/10 扩展的当前要求是什么,以便我可以确保生成适当的文件结构。

有谁知道以下文件结构是否是当前的:

MyExt/
    chrome/
        chrome/chromeFiles/
            chrome/chromeFiles/content/
                MyExt.js
    defaults/
        defaults/preferences/
            prefs.js
    chrome.manifest
    install.rdf

原始编译器为不修改浏览器镶边的 Greasemonkey 脚本输出此文件:

MyExt/
    chrome/
    content/
        MyExt.js
        prefs.js
        compiler.js
        xmlhttprequester.js
    chrome.manifest
    install.rdf

下一步将是确保编译器使用的 Greasemonkey 代码是最新的,但是我想首先明确我的产出目标。

I'm working on updating a Greasemonkey compiler to package Firefox extensions. I think the original version was for Firefox version 3.6 and Greasemonkey version 0.7.20070607.0, and the source code is on GitHub here. I'm going to be working on my update here.

I'm trying to figure out what the current requirements are for Firefox 9/10 extensions so that I can make sure that I am generating the appropriate file structure.

Does anyone know if the following file structure is the current one:

MyExt/
    chrome/
        chrome/chromeFiles/
            chrome/chromeFiles/content/
                MyExt.js
    defaults/
        defaults/preferences/
            prefs.js
    chrome.manifest
    install.rdf

The original compiler outputs this for a Greasemonkey script that does not modify the browser chrome:

MyExt/
    chrome/
    content/
        MyExt.js
        prefs.js
        compiler.js
        xmlhttprequester.js
    chrome.manifest
    install.rdf

The next step will be to make sure that the Greasemonkey code that the compiler uses is current, but I want to get my output goals clear first.

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

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

发布评论

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

评论(1

别靠近我心 2025-01-01 03:44:35

这是一个典型/可接受的结构(尽管大多数人不会将 content 嵌套在 chromeFiles 下;chrome/content 就足够了)。典型的结构可以在此处找到

my_extension.xpi:             //Equal to a folder named my_extension/
  /install.rdf                //General information about your extension
  /chrome.manifest            //Registers you content with the Chrome engine
  /chrome/
  /chrome/content/  //Contents of your extension such as XUL and JavaScript files
  /chrome/icons/default/*     //Default Icons of the extension
  /chrome/locale/*            //Building an Extension# Localization
  /defaults/preferences/*.js  //Building an Extension# Defaults Files
  /plugins/*
  /components/*
  /components/cmdline.js

但是,请注意以下事项:

That's a typical/acceptable structure (although most people wouldn't nest content under chromeFiles; chrome/content is sufficient). A typical structure can be found here:

my_extension.xpi:             //Equal to a folder named my_extension/
  /install.rdf                //General information about your extension
  /chrome.manifest            //Registers you content with the Chrome engine
  /chrome/
  /chrome/content/  //Contents of your extension such as XUL and JavaScript files
  /chrome/icons/default/*     //Default Icons of the extension
  /chrome/locale/*            //Building an Extension# Localization
  /defaults/preferences/*.js  //Building an Extension# Defaults Files
  /plugins/*
  /components/*
  /components/cmdline.js

However, note the following:

  • The files under chrome can actually be placed anywhere you want, as long as you register those locations properly in the chrome.manifest

  • Components can also be located anywhere. As with the chrome files, the location must be registered in the manifest.

  • Defaults, on the other hand, must be in the defaults folder:

    Defaults files that you use to seed a user's profile with should be
    placed in defaults/ under the root of your extension's folder
    hierarchy. Default preferences .js files should be stored in
    defaults/preferences/ - when you place them here they will be
    automatically loaded by Firefox's preferences system when it starts so
    that you can access them using the Preferences API.

  • Both install.rdf and chrome.manifest should reside in the top-level directory of the extension

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