move book generation functionality into content.js