record.js, waveform.js: add Sebastian's patch to simplify the code