Creating new event using js only

Hello there, i am aware that i had posted this back when in a different thread, but still im searching for answers how can it be possible to create new event using javascript.
In looking upon other scripts, ive noticed that they first check the last number of existing event then make the next event the new event. Some find the first blank/undefined slot then replace it with an event.
I know this is complicated, but if anyone has a knowledge how this can be done, kindly comment bellow
I appreciate any help, thank you in advance

by the way. Im using MV
I think this will help. Orange Custom Event Creator
thanks bro (sis if female)

Original thread: https://forums.rpgmakerweb.com/threads/creating-new-event-using-js-only.80118/