How can I duplicate “Add Custom Field” with just JavaScript?

Quick search shows that related part of form is generated by meta_form() function. Start from there I guess.

Also note that you will need to retrieve from source and submit nonce that protects that form. I am not sure if submitting single field invalidates the nonce there, but that also might be the case.