I think we’ve all been there. That place where you have to manually change about a bazillion database records via a laborious web-interface. I was there today. I had to change the details of roughly 300 Flyspray bug reports and it wasn’t going to be fun.
Here’s what I had to do to make these database records right:
- Click “next task” to move to the next record.
- Click “Edit this Task” to edit the record.
- Change the Bug Type drop-down from “Bug” to “Feature Request.”
- Change the Bug Status drop-down from “Unassigned” to “Assigned.”
- Change the Assigned To drop-down from “Unassigned” to my own name.
- Change the Due in Version drop-down from “Undetermined” to version 1.3.
- Click “Save Details.”
So, that’s 7 clicks per record. Let’s see, 7 x 300 records = a recockulus pain in the ass.
By about the fifth record I started pining for some kind of web macro system to make this much easier. After much whining and bitching, I slapped my forehead – there is already one, and it’s Greasemonkey, of course.
The script was ready in seconds:
// ==UserScript==
// @name Poopulator
// @namespace http://www.yermom.com
// @description A template for creating new user scripts from
// @include http://www.yermom.com/flyspray/?do=details&id=*&edit=yep
// ==/UserScript==
var type = document.getElementById("tasktype");
type.selectedIndex = 1;
var status = document.getElementById("status");
status.selectedIndex = 2;
var user = document.getElementById("assignedto");
user.selectedIndex = 1;
var version = document.getElementById("dueversion");
version.selectedIndex = 2;
Basically, when the edit page loads, find the dropdowns and set them to their right values.
Not even sure if the wildcard value for id query string variable in the @include area would even work, I gave it a shot. It did, as well as the rest of the script. It worked like a charm, in fact. Now, simply editing a task automgically sets all those dropdowns perfectly. It’s not the most polished thing in the world, but it’s probably going to save me hours of time.
It made me very happy. So very, very happy. Enough to go tell it to my LiveJournal.
