
// Autoselect Pearson Access role
// version 0.1 BETA!
// 2008-11-12
// Copyright (c) 2008, Jesse Peterson
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.  To install it, you need
// Greasemonkey 0.3 or later: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Hello World", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name          Auto Select Pearson Access role
// @namespace     http://www.jpeterson.com
// @description   Script to automatically select a Pearson Access role
// @include       http://www.yourdomain.com/context/yourapp/*
// ==/UserScript==

//GM_log('auto select running');

var h3s = document.evaluate(
    "//h3[.='your create new user']",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);
    
if (h3s.snapshotLength) {
//  GM_log('running on New User Account');

  var roleCheckbox = document.evaluate(
    "//input[@value='your_role_value']",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);

  var thisRoleCheckbox;
  for (i=0; i < roleCheckbox.snapshotLength; i++) {
//    GM_log('found role checkbox');
    
    thisRoleCheckbox = roleCheckbox.snapshotItem(i);
    if ((thisRoleCheckbox.type == 'checkbox') && (!thisRoleCheckbox.checked)) {
//      GM_log('checking role checkbox');
      thisRoleCheckbox.checked = true;
    }
  }

}

