Make Your Own Scripts

How To Make Script

Add Script

Click [Add Script...] button in [Mappings] pane.
Enter [Name], [Script] and [Gesture] in [FireGestures Edit] dialog.

Scripting Guide

API

FireGestures.sourceNodeThe DOM Node at the starting point of gesture.
event.targetThe DOM Node at the ending point of gesture.
FireGestures.getLinkURL(aNode)Returns the link URL inside aNode.
Returns null if aNode is not a link.
FireGestures.getImageURL(aNode)Returns the URL of the image if aNode is <img> element.
Returns data:URL if aNode is a <canvas> element.
In other cases, returns null.
FireGestures.getSelectedText()Returns the selected text.
FireGestures.gatherLinkURLsInSelection()Returns an array of link URL inside the selection.
FireGestures.checkURL(aURL, aDoc, aFlags)Wrapper function of Firefox's urlSecurityCheck, which throws an exception if opening aURL from a document aDoc is unsafe.
FireGestures.setStatusText(aText)Displays aText in the status bar.
FireGestures.clearStatusText(aMillisec)Clears text in the status bar after aMillisec milli-seconds.
FireGestures.generatePopup(event, aAttrsList)Generates popup from an array of attributes for xul:menuitem elements. See 'Example 2' below.
FireGestures.sendKeyEvent(aOptions)Emulates a keyboard input. aOptions is an object which may have 6 properties: ctrl, alt, shift, meta, key, keyCode. See 'Example 3' below.

Example 1

// get the DOM node at the starting point of gesture
var srcNode = FireGestures.sourceNode;
// get the link URL inside the node
var linkURL = FireGestures.getLinkURL(srcNode);
if (!linkURL)
    throw "Not on a link";
// check the URL is safe
FireGestures.checkURL(linkURL, srcNode.ownerDocument);
// open link in new tab
var background = gPrefService.getBoolPref("browser.tabs.loadInBackground");
if (event.shiftKey || event.ctrlKey)
    background = !background;
gBrowser.loadOneTab(linkURL, null, null, null, background, false);

Example 2

FireGestures.generatePopup(event,
	[
		{ label: "Downloads",     oncommand: "document.getElementById('Tools:Downloads').doCommand();" },
		{ label: "Add-ons",       oncommand: "document.getElementById('Tools:Addons').doCommand();" },
		{ label: "Error Console", oncommand: "toJavaScriptConsole();" },
	]
);

Example 3

// press 'Ctrl+Shift+A' to open Add-ons Manager
FireGestures.sendKeyEvent({ ctrl: true, shift: true, key: "A" });

TOP