📜 ⬆️ ⬇️

A few words about the development and publication of add-ons for FireFox and Chrome

image
The other day I broke off an invite to leprosy. In this connection, there was a desire to experiment with plug-ins to display images from the comments to the post. Not a word further about leprosy, just a few theses about writing and publishing a simple or slightly more than simple add-on for FireFox and Chrome. Well, in the end - links to crafts.

Context


JS code processed on a web page and JS code add-it are processed in different contexts. You will not be able to call spriting functions embedded in a web page from your add-on and vice versa. I will give two examples:

Using external js frameworks


In order to be used in its add-on js-framework, it must be inserted directly into the add-on. For FireFox, this is done as follows. First, copy the framework file (in my case, jquery.js) to the “content” directory of your add-on, and then use the external script dynamic loading code:
Components.classes["@mozilla.org/moz/jssubscript-loader;1"].
getService(Components.interfaces.mozIJSSubScriptLoader).
loadSubScript("chrome://leprokartinki/content/jquery.js");

In my case, this code is placed in the window.addEventListener("load",...) handler window.addEventListener("load",...)

The chrome is a bit simpler. You place the file (in my case, jquery.js) in the add-on folder and then simply specify it in manifest.json along with the rest of the js files used.

After these manipulations in add-on, it is possible to use the framework functionality.
')
I could not use the jQuery clone function of clone() objects in an add-on. Later I did without cloning. How this feature behaves in the chrome I did not check. There are assumptions about the causes of the error, but I did not dig.

Official publication of add-ons


FireFox allows you to freely publish your crafts to the gallery and, over time, assigns statuses to add-ons (“Not Verified”, “Pre-Verified”, “Verified”). Between status changes it takes from several days to several weeks. The status of add-on influences its entry into selections and ratings.
But chrome for the possibility of official publication in its store requires a fee for registration of the developer ($ 5). Only after that your add-on will be available for free download and installation.

Talmud for those who want to try


  1. Creating an extension for FireFox
  2. Getstarted for Crome

PS: Two of my crafts - plug-ins to view all the pictures of the post leprosy - I posted here (FireFox) and here (Chrome) .
UPD: Another FireFox trick - replaces a Skype phone numbers, found on a web page, with links to a telephone directory with information about these numbers.

Source: https://habr.com/ru/post/119343/


All Articles