Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
loadModule("Gerbrant.gui.lilink", function(li)
{
	module("Gerbrant.gui.toolbox", new function()
	{
		var self = this;
		var docLoaded = false;
		var waiting = [];

		this.objects = [];

		// no this
		function reallyAddObject(obj)
		{
			li.addToolboxLink("javascript:void(Gerbrant.gui.toolbox.objects[" +
				self.objects.length + "].show())", obj.caption);
			self.objects.push(obj);
		}

		// no this
		this.addObject = function(obj)
		{
			if(docLoaded) reallyAddObject(obj);
			else waiting.push(obj);
		}

		hookEvent("load", function()
		{
			var i;
			docLoaded = true;
			for(i in waiting) reallyAddObject(waiting[i]);
			delete waiting;
		});

		try
		{
			var i, l = Gerbrant.gui.toolbox.load, x, n;
			for(i in l)
				if((n = (x = l[i])[0]) == undefined)
					loadModule(x, this.addObject);
				else
					(function(args)
					{
						loadModule(n, function(c)
						{
							var o = {};
							c.apply(o, args);
							self.addObject(o);
						});
					})(x.slice(1));
		}
		catch(e)
		{
		}
	});
});