Removing the default work offset (or changing it to something else) is easy enough, it is in the following line (the gFormat.format(54) call) ...
writeBlock(gAbsIncModal.format(90), gFormat.format(54), gFormat.format(64), gFormat.format(50), gPlaneModal.format(17), gFormat.format(40), gFormat.format(80), gFeedModeModal.format(94), gFormat.format(91.1), gFormat.format(49));
That line is in the onOpen() bock.
Making it output the correct work offset will be a little more tricky. You will have to get the first section (containing the first work offset) and then convert it to gcode. This is how it is done in the onSection() block ...
var workOffset = currentSection.workOffset;
if (workOffset == 0) {
warningOnce(localize("Work offset has not been specified. Using G54 as WCS."), WARNING_WORK_OFFSET);
workOffset = 1;
}
if (workOffset > 0) {
if (workOffset > 6) {
var p = workOffset; // 1->... // G59 P1 is the same as G54 and so on
if (p > 9) {
error(localize("Work offset out of range."));
} else {
if (workOffset != currentWorkOffset) {
p = 59 + ((p - 6)/10.0);
writeBlock(gFormat.format(p)); // G59.x
currentWorkOffset = workOffset;
}
}
} else {
if (workOffset != currentWorkOffset) {
writeBlock(gFormat.format(53 + workOffset)); // G54->G59
currentWorkOffset = workOffset;
}
}
}
But you probably only need to do something like the following (right before that long line) ...
var firstSection = getSection(0);
var firstWorkOffset = firstSection.workOffset;
and then (in that long line) replace gFormat.format(54) with gFormat.format(59 + firstWorkOffset / 10.0);