How to use the library?
![]() ![]() |
How to use the library? |
![]() ![]() |
DEPRECIATED Include it in a Userscript using the @require metadata key. E.g.
// @require http://userscripts.org/scripts/source/56812.user.js You can then use the function GMailAPI( ... ); to make use of the API, with the only parameter being a object with several options. Some examples: (Note: read this http://code.google.com/p/gmail-greasemonkey/wik... first)
GMailAPI({
onViewChange: function() {
// Is called when GMail changes 'view'.
this; // Contains a few handy bits and pieces.
}
});Notice I used the variable this in the onViewChange function, it contains the following (list may change without notice at any time):
this.info; // Contains info about the GMonkey API this.viewType; // Contains the current view type. I.e. gmail.getActiveViewType this.canvasElement; // Contains the curent canvas element this.viewElement; // Contains the current view element. E.g. gmail.getActiveViewElement this.navElement; // Contains current navigation element this.mastheadElement; // Contains masthead element this.labelsElement; // Contains labels element this.convRhsElement; // Contains RHS element. I think an example is the chat box this.footerElement; // Contains the footer element this.addNavModule( params, ... ); // Add's a navigation module, see document at link above this.clickElement( element ); // Clicks the given element |
![]() ![]() |
It doesn't seem to work for me...
alert("");
GMailAPI({
onViewChange: function() {
// Is called when GMail changes 'view'.
alert(this.info);
}
});,
I get the first message box, but nothing else...
|
![]() ![]() |
To make an @require work, you have to re-install the script after adding the @require line. This is due to Greasemonkey only loading @requires's on installation. |


