Refactor code: move request stuff to index.js, make postMessage function generic