void reframe(buffer results) {
// Remove menuset. This is unnecessary for icon style menu
matcher menuset = create_matcher('(<[^>]*menuset[^\\d]*(\\d*)[^>]*>)', results);
if(menuset.find()) {
results.replace_string(menuset.group(1), "");
results.replace_string("</frameset><frame name=chatpane", "<frame name=chatpane");
// Move charpane out of frameset & change columns of rootset
matcher charpane = create_matcher('(<[^>]*charpane[^/]*/frame>)', results);
if(charpane.find()) {
results.replace_string(charpane.group(1), "");
results.replace_string('cols="4*,*">', 'cols="200,3*,*">'+charpane.group(1));
}
// Move menupane down to top of mainset above mainpane
matcher menupane = create_matcher('(<[^>]*menupane[^/]*/frame>)', results);
if(menupane.find()) {
results.replace_string(menupane.group(1), "");
results.replace_string('<frame name=mainpane', menupane.group(1)+'<frame name=mainpane');
}
// Change mainset cols to rows, copy menu height from menuset
matcher mainset = create_matcher('(<[^>]*mainset[^>]*)cols([^>]*)200([^>]*>)', results);
if(mainset.find())
results.replace_string(mainset.group(0), mainset.group(1)+"rows"+mainset.group(2)+menuset.group(2)+mainset.group(3));
}
}
void main() {
buffer results = visit_url();
results.reframe();
// add doctype to escape quirks mode
results.replace_string('<html>', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n<html>');
results.write();
}