buffer annotate(buffer page) {
buffer c;
matcher choices = create_matcher("<input type=hidden name=pwd value='[^']+'><input type=hidden name=whichchoice value=(\\d+)><input type=hidden name=option value=(\\d)>", page);
while(choices.find())
choices.append_replacement(c, choices.group(2)+": "+choices.group(0));
choices.append_tail(c);
// Add choiceAdventure number to title
matcher title = create_matcher('<input type=hidden name=whichchoice value=(\\d+)>.+(</form></center></td></tr>)</table></center>', c);
if(title.find())
return c.replace_string(title.group(2), title.group(2)+"<tr><td><span style='float:right;color:blue;font-weight:bold'>choiceAdventure"+title.group(1)+"</span></td></tr>");
return c;
}
void main() {
visit_url().annotate().write();
}