This repository has been archived by the owner on Aug 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
Custom commands
bard edited this page Sep 13, 2010
·
9 revisions
New commands can be added to the REPL through an initialization file. Go to the about:config URL, find extensions.mozlab.mozrepl.initUrl, and set this value to a local URL (chrome:// or file://). The URL contents will be loaded in the REPL. Example:
First, set extensions.mozlab.mozrepl.initUrl to file://localhost/tmp/custom.js
, then Create a /tmp/custom.js
file with the following content:
var startedAt = new Date();
function report() {
this.print('I was started at ' + startedAt);
}
Every time you start a REPL, you’ll be able to read a repl.startedAt
property and invoke a repl.report()
method.
Feel free to add commands here that can be used in one’s MozRepl init file.
- Command: Simple DOM Grabber – Grab a DOM element by clicking it with the mouse.
- Command: DOM Grabber #2 – Grab a DOM element by clicking it with the mouse. Also with item highlighting.
- Command: DOM Grabber #3 – Yet another variant, this time with the current element reported in the title bar and highlighted as mouse moves over it
- Command: getWindows() – Return a list of currently opened windows