refactor main_hook to a function
Merge pull request #520 from niphlod/js/main_hook

refactor main_hook to a function