2011
03.19

FireQuery fun

2 people like this post.
Share

Or how to toggle a thousand checkboxes clicking none.
Have you ever wondered that jQuery may be relevant to your everyday sysadmin job? It is: web-based GUIs proliferate and the Command Line is sooo nineties (this one’s not mine)…
Working on a SonicWALL/Aventail SSL VPN box, I was asked to simplify how permissions were mapped to Users. What a User could or couldn’t do, was defined at the User level. Ok, let’s just:

  • Create an A/D group for each role/profile.
  • Configure permissions (rules, resources access, …) on various Communities (Aventail parlance for roles/profiles).
  • Put the right Users into the right A/D group.
  • Cleanup: generally, each Community should just have A/D groups assigned to it. Get rid of unnecessary Community memberships.

First three tasks were easy (thanks also to the DS* commands). The fourth, uhm:

Removing members from a Community means unchecking each User. In my case, more than one thousand clicks and a beginning of carpal tunnel syndrome. At page three I started to think about a less saddening way.

FireQuery is a Firefox extensions that let’s you “inject” jQuery into any webpage. Here’s what I did:

  • Went to the page depicted above (the one that let’s you assign members to a Community).
  • Launched Firebug.
  • Inspected the DOM and noticed that each of the checkboxes value begins with “AV”.
  • Used the debugger to see what’s going on when checking/unchecking members. Nothing really strange: just a bit of JavaScript to highlight a row depending on its checkbox’s status.
  • Hit the jQuerify button. FireQuery is needed because Aventail’s web-based GUI doesn’t use jQuery.
  • Went to Console, typed the JavaScript one-liner below and hit Run
$('input[value^="AV"]').attr('checked', false)

which translates to: use jQuery to select all of the checkboxes whose value starts with “AV”. Uncheck the selected checkboxes.

See? No useless clicking: a GUI has been CLI-fied.

Share