Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to develop Firefox plug-ins quickly

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

In this issue, the editor will bring you how to quickly develop the Firefox plug-in for Sina Weibo. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

Plug-in mechanism of Firefox

For a Firefox plug-in, the first thing we need to understand is its organizational structure. Open a Firefox plug-in project, you will usually look at the following elements: chrome folder, defaults folder, chrome.manifest, install.rdf.

Let's start with install.rdf. You know what this file is for compared to the name of the file. Yes, this file is the installation file for the Firefox plug-in.

Flashcard@gmail.com 0.7 2 flashcard Post the selected word to Sina weibo. Https://feihe.cnblogs.com chrome://flashcard/skin/icon.png Fei He {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 3.0 4.0.*

There are some descriptions of your Firefox plug-in, of which the two key ones are the id of your Firefox plug-in under the root node description, which means that this thing must be unique (at least among all your Firefox plug-ins), and the other is Firefox's id, which cannot be modified. Then there are and, they are used to describe the compatibility of your Firefox plug-in with the Firefox version.

Then let's take a look at defaults. In a word, defaults is the default setting of your Firefox plug-in's preferences.

The core parts of a Firefox plug-in are the chrome.manifest and chrome folders. Chrome.manifest is a bit like a .NET project file, which is basically the location information of all elements of the entire Firefox plug-in, and Firefox itself uses this manifest to locate specific elements. So what elements will a Firefox plug-in contain? Open chrome.manifest and you'll see.

Overlay chrome://browser/content/browser.xul chrome://flashcard/content/overlay.xul

Content flashcard chrome/content/flashcard/

Skin flashcard classic chrome/skin/classic/flashcard/

Locale flashcard en-US chrome/locale/flashcard/en-US/

Style chrome://global/content/customizeToolbar.xul chrome://flashcard/skin/skin.css

The structure in this is basically a row structure, and the header of each line is the specific name of the Firefox plug-in element, followed by telling Firefox where to look for this element. And this contains the following elements:

◆ overlay: a UI element that points to your Firefox plug-in, including contextmenu,toolbar,navigator bar and the like. As you can see in the manifest above, I point to a file with the suffix xul, but its full name is Xml User Interface. As the name implies, UI is described in the format of xml.

Above is an overlay.xul I use. Here I add a new menuitem to Firefox's contextmenu and use separator to separate it from the original menuitems. The file name here is optional, and the name you choose must be used in chrome.manifest. Many people here are curious, so where is the corresponding behavior of the menuitem you added? If you are careful, you may find that some javascript is referenced in my xul, but for us, menuitem,Firefox provides two ways to disassociate behaviors: the first is to specify the behavior of control directly in the oncommand of control; the second is to use document.getElementByID in javascript to obtain control to bind the behavior:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report