Use JS to fix #334