Modify js code to remove empty divs automatically

Signed-off-by: Jonathan <jona.tw@gmail.com>