background preloader

Building an extension

Building an extension
Introduction This tutorial will take you through the steps required to build a very basic extension - one which adds a status bar panel to the Firefox browser containing the text "Hello, World!". Note: The extension created by this tutorial won't work in Firefox versions that don't have a static status bar (that is, Firefox 4 and up). You can find a more up-to-date tutorial in the XUL School tutorial The Essentials of an Extension. Since Firefox 4 (and other Mozilla 2 based applications) there are two types of extensions: Traditional, classic, or XUL extensions are more powerful, but more complicated to build and require a restart to install. This article explains how to build a traditional extension for Firefox. For a tutorial on building an extension for Thunderbird, see Building a Thunderbird extension. Quick Start A Hello World extension similar to what you can generate with the Extension Wizard is explained line-by-line in another tutorial from MozillaZine Knowledge Base. <? XUL Overlays

DOM Reference - Document Object Model (DOM) The Document Object Model (DOM) is a programming interface for HTML and XML documents. It provides a structured representation of the document (a tree) and it defines a way that the structure can be accessed from programs so that they can change the document structure, style and content. The DOM provides a representation of the document as a structured group of nodes and objects that have properties and methods. Though often accessed using JavaScript, the DOM is not part of it and it can be used by other languages, though this is much less common. An introduction to the DOM is available. DOM interfaces Obsolete DOM interfaces The Document Object Model is in the process of being heavily simplified. HTML interfaces A document containing HTML is described using the HTMLDocument interface. HTML element interfaces Other interfaces Obsolete HTML intefaces SVG interfaces SVG element interfaces SVG data type interfaces Static type Animated type SVG Path segment interfaces Other SVG interfaces See also

Window - Web API reference Note that properties which are objects (e.g., for overriding the prototype of built-in elements) are listed in a separate section below. Window.caches Read only Secure context Returns the CacheStorage object associated with the current context. This object enables functionality such as storing assets for offline use, and generating custom responses to requests. Window.clientInformation Read only An alias for Window.navigator. Window.closed Read only This property indicates whether the current window is closed or not. Window.cookieStore Read only Secure context Returns a reference to the CookieStore object for the current document context. Window.credentialless Read only Experimental Returns a boolean that indicates whether the current document was loaded inside a credentialless <iframe>. Window.crossOriginIsolated Read only Returns a boolean value that indicates whether the website is in a cross-origin isolation state. Window.crypto Read only Window.customElements Read only Window.document Read only

Developer Network Tabs configuration, extracted from About:config entries - MozillaZine Knowledge Base Location: This page was created to be a companion of my page on Tabbed Browsing in Firefox. The table on this page consisting of selected tab and window items has been extracted from which is part of the MozillaZine_Knowledge_Base article Heuer's Razor: "If it can't be turned off, it's _not_ a feature." (is often quoted in Developer groups.) This listing is basically comprised of entries selected from the mozillaZine article About:config entries dealing with tabs and is mainly from the following groups: browser.link. ... browser.search. ... browser.tabs. ... Note: Spaces between the dots in preference names exist purely for word-wrapping. To find values related to an about:config configuration entries Type about:config into the location bar. Testing of Ctrl+TAB Sorting Preferneces:

window.history - Web API reference « Window The Window.history read-only property returns a reference to the History object, which provides an interface for manipulating the browser session history (pages visited in the tab or frame that the current page is loaded in). Syntax var historyObj = window.history; The obtained History object has the following methods:See Manipulating the browser history for examples and details. Example history.back(); history.go(-1); Notes For top-level pages you can see the list of pages in the session history, accessible via the History object, in the browser's dropdowns next to the back and forward buttons. For security reasons the History object doesn't allow the non-privileged code to access the URLs of other pages in the session history, but it does allow it to navigate the session history. There is no way to clear the session history or to disable the back/forward navigation from unprivileged code. See also Specification HTML5 History interface Document Tags and Contributors

Tabbed browser - Code snippets Here you should find a set of useful code snippets to help you work with Firefox's tabbed browser. The comments normally mark where you should be inserting your own code. Each snippet normally includes some code to run at initialization, these are best run using a load listener. These snippets assume they are run in the context of a browser window. If you need to work with tabs from a non-browser window, you need to obtain a reference to one first, see Working with windows in chrome code for details. Multiple meanings for the word 'browser' The word 'browser' is used several ways. Getting access to the browser From main window Code running in Firefox's global ChromeWindow, common for extensions that overlay into browser.xul, can access the tabbrowser element using the global variable gBrowser. // gBrowser is only accessible from the scope of // the browser window (browser.xul) gBrowser.addTab( Basically, if your extension code is a sidebar you can use: From a dialog Opening a URL in a new tab or

Getting started with extension development From MozillaZine Knowledge Base Two major extension developers' features introduced in Firefox 1.5 were the greatly simplified chrome registration scheme and the reworked Extension Manager. These changes make it even easier to start writing extensions. This article describes steps needed to get started with extensions development. Last two sections have a few development tips and packaging information. It's a wiki page, so feel free to make improvements to this page and to add your feedback on the Talk page. Extensions created in this way will only work on Firefox/Thunderbird 1.5 and later, but you should be able to make changes to ensure your extension is compatible with Firefox 1.0 quite easily. Again, this will work only in Firefox/Thunderbird 1.5 or later, not 1.0.x! Setting up your environment This article focuses on Firefox extensions, although it also applies to other Toolkit applications, such as Thunderbird. What this Extension Does This extension adds an item called 'Hello World!'

Add-on Builder The Add-on Builder was a web-based development environment that allowed developers to create add-ons using the SDK APIs, but without needing to use the cfx command line tool. It was retired on April 1, 2014, and the "builder.addons.mozilla.org" domain now redirects to this page. If you have only used the SDK through the Builder, you already know most of what you need to know to develop using just the SDK. The high-level and low-level APIs used for Builder add-ons are exactly the same for Builder and SDK. install the SDK locally get to know the cfx command line tool, with this introductory walkthrough and the detailed cfx reference get to know the package.json file used to configure attributes of your add-on

18.2. json — JSON encoder and decoder — Python v2.7.5 documentation Extensible JSON encoder for Python data structures. Supports the following objects and types by default: To extend this to recognize other objects, subclass and implement a default() method with another method that returns a serializable object for o if possible, otherwise it should call the superclass implementation (to raise TypeError). If skipkeys is false (the default), then it is a TypeError to attempt encoding of keys that are not str, int, long, float or None. If skipkeys is true, such items are simply skipped. If ensure_ascii is true (the default), all non-ASCII characters in the output are escaped with \uXXXX sequences, and the results are str instances consisting of ASCII characters only. If check_circular is true (the default), then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an OverflowError). Note If specified, separators should be an (item_separator, key_separator) tuple.

simplejson — JSON encoder and decoder — simplejson v2.1.1 documentation Extensible JSON encoder for Python data structures. Supports the following objects and types by default: To extend this to recognize other objects, subclass and implement a default() method with another method that returns a serializable object for o if possible, otherwise it should call the superclass implementation (to raise TypeError). If skipkeys is false (the default), then it is a TypeError to attempt encoding of keys that are not str, int, long, float or None. If ensure_ascii is true (the default), the output is guaranteed to be str objects with all incoming unicode characters escaped. If check_circular is false (the default), then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an OverflowError). If allow_nan is true (the default), then NaN, Infinity, and -Infinity will be encoded as such. Changed in version 2.1.0: Changed indent from an integer number of spaces to a string.

Related: