-
Notifications
You must be signed in to change notification settings - Fork 20
Notes for Addon Reviewers
If you test the extension, the preferred OS is Windows. Everything works in OSX/Linux, but the context menu interferes with gestures when the gesture button is right button. The reason for this is described in this BugZilla entry: https://bugzilla.mozilla.org/show_bug.cgi?id=1360278
Program flow is generally as follows:
-
A mouse event is generated in a tab or nested frame and bubbles up via content/mouseEvents.js in the manner described in the README under Working Principle.
-
content/handler.js is called from
mouseGestures.js
when a gesture begins, updates, or ends.content/handler.js
accumulates mouse movements and performs gesture detection. -
When a gesture is detected,
content/handler.js
sends a message to background/handler.js. The background script looks up the mapping for the gesture and invokes the command. A mapping is a tuple of gesture and command, for example:'ULR' -> 'scrollToTop'
. -
Privileged commands are implemented in background/commands.js. Some commands in this file are stubs that forward a message back to content/commands.js via
content/handler.js
typically because the command needs page/DOM access.
There is some additional messaging related to features like status text and wheel gestures, but the overall program generally follows this flow.
This is a feature similar to Greasemonkey that allows a user to execute user provided JavaScript snippet when a mouse gesture is performed.
User scripts can only be input in the options page. The feature is not enabled until the user dismisses a warning describing the risks of self-XSS attacks. The warning looks like this.
User scripts are evaluated using eval()
in content/commands.js
. When a user script requires access to privileged APIs, I provide a function called executeInBackground()
that can be used to execute code in background/commands.js
again with eval()
. This is all documented in the wiki article on user scripts.
There are use cases for user scripts that use privileged APIs, for example: I often use quick UD gesture mapped to a script that downloads the image under the mouse using a filename prefixed with the domain.
I've received some criticism for using Angular here. Angular is only used for the options page. Angular is never injected into content scripts. I know it is a large framework, but it is the framework with which I am most familiar. This allowed me to develop the extension much faster than any alternative. I think the options page is complex enough to justify using a framework.
In addition to Angular, I am using the following libraries:
- ui-bootstrap: A pure Angular implementation of Bootstrap 3 components.
- ACE editor: A syntax-highlighting input box for use with the user scripts feature.
- ui-ace: Angular directive to integrate ACE editor.