The implementation of window.scratch in Javascript.