I’ve created my first plugin for Firefox. It turned out to be easier than I thought. However, it was so easy beacause I didn’t have to interfere Forefox menu. If I hafd to, I would use XUL, which would be tough.
What I was supposed to do, was to add a link Post to notitio.us to articles on wiki that use MediaWiki engine. The link should be placed in the right menu in a box, where link Help is. I decided to use only JavaScript and test the code with GreaseMonkey plugin for Firefox. In short, GreaseMonkey allows to run a specified JavaScript on declared web pages.
So I ended up with the following JavaScript code:
// ==UserScript==
// @name IKHarvesterWikiPlugin
// @namespace http://notitio.us/IKHarvesterWikiPlugin
// @description Adds to Wikipedia pages "Post to notitio.us" link
// @include http://*wiki*/*
// @exclude *url=*
// ==/UserScript==
(function () {
var IKHarvesterWikiPlugin = {
addPostToNotiotiousLink: function() {
var li = document.createElement("li");
li.setAttribute("id", "notiotious");
li.setAttribute("title","Added by IKHarvester plugin");
li.innerHTML = ' \
<a title="Post to notitio.us" \
href="http://notitio.us/ikharvester/addLO.jsp?m=1&url='+
window.location.href+'\" \
style="color:red; font-weight:bold;">Post to notitio.us</a>'
document.getElementById("n-help").parentNode.appendChild(li);
}
}
IKHarvesterWikiPlugin.addPostToNotiotiousLink();
})();
I’ve tested with GreaseMonkey and it worked. So it could be used by anyone who used GreaseMonkey plugin. Then I stared to think how to create a real add-on to Firefox, an xpi file added to Firefox. I’ve found User Script Compiler, a service that compiles GreaseMonkey scripts to real add-ons. Compilation finished with success, and the plugin is available here
So, GreaseMonkey and User Script Compiler allow to create Firefox add-ons. The former can be used during development and testing stage, while the latter generates the final add-on. User Script Compiler creates JavaScript, xul, and other files that are required so that the plugin works. However, you can do it this way only if you don’t plan to add items to Firefox menu and taskbar. Actually, this way you can create only simple extensions. Anyway, sometime it’s just what you want


