public
Description: Firefox extension allowing for stored micro-bookmarking using tabs.
Home | Edit | New

Tab Scripting

Introduction

This functionality is designed to make it possible for a user to open a tab, and automate the user actions required to get that tab to a usable state. A lot of the time this means a login, or clicking on some content to dynamically configure the page. Using the MozMillController you can basically simulate anything in that tab that a user could do making this functionality very powerful and useful.

Objects in Scope

  1. win – The content window for the tab.
  2. doc – The content document for the tab
  3. tab – An instance of MozMillController scoped to the tab content window.
  4. elementslib – The elementslib object, allowing for lookups of elements on the page to interact with

Example Scripts

Facebook Login


//Lookup the three elements I want to interact with var email = new elementslib.ID(doc, 'email'); var pass = new elementslib.ID(doc, 'pass'); var login = doc.getElementsByClassName('UIButton_Text')[0];

//Controller expects elementslib objects
var elibLogin = new elementslib.Elem(login);

//Tell the controller to type the credentials
tab.type(email, ‘my_facebook_account@address.com’);
tab.type(pass, ‘my_password’);
//Click the login button
tab.click(elibLogin);

Wordpress Login


//Lookup the three elements I want to interact with var uname = new elementslib.ID(doc, 'user_login'); var pass = new elementslib.ID(doc, 'user_pass'); var login = new elementslib.ID(doc, 'wp-submit');

//Tell the controller to type the credentials
tab.type(uname, ‘wordpress_username’);
tab.type(pass, ‘wordpress_password’);
//Click the login button
tab.click(login);

More Resources

  1. All the available functions in the controller, here named ‘tab’
  2. Elementslib documentation, explaining all the ways to access elements on the page
Last edited by admc, Mon Aug 24 00:48:38 -0700 2009
Home | Edit | New
Versions: