IllegalAccessException, IOException {
WebWrapper ww = new WebWrapper(getJavaScriptPath());
ww.loadProgram(getProgram());
ww.runProgram();
URI uri = replayStringToUri(replaySource);
XMLHttpRequest xhr = new XMLHttpRequest();
xhr.open("GET", uri.toString());
try {
xhr.send();
} catch (IOException e) {
System.err.println("Could not load " + replaySource + ": " + e);
System.exit(1);
}
String replayStr = xhr.getResponseText();
ScriptableObject replay = ww.construct("Replay",
new Object[] { replayStr });
ScriptableObject meta = (ScriptableObject) replay.get("meta", replay);
NativeArray playernames = (NativeArray) meta.get("playernames", meta);
int userIndex = playernames.indexOf(botInput.getPlayer());