Randomization and participants number

URL of experiment:

Description of the problem:
Currently we have a dialogue option at the beginning of experiment, where participant number can be inserted. Running an experiment online, It would be a problematic to have all participants number in order. I would like to hide that dialogue option. Is any way to program it in a way that experiment pick a participant number from a file like txt, or csv, assign to actual participant and then changing the participant number in the file + 1? Then for the next participant it, picks up that number assign it to the next participant and change it + 1. And it continues until the study is done.

The same issue with randomisation of conditions. I of course could specify something like this random.choice((‘A’,‘B’)). But then again it is less like my groups will have the same numbers. I think the better way would be if the program pick up that info from the file. For example, if previous participant had a conditon A then the current one gets B. and visa versa If previous got B then the current one gets an A. And of course, it should rewrite that file at the beginning of experiment to avoid any problems if for example 10 participants will start doing it in aprx. the same time.

I am not sure what is the best way how it can be implemented in python and javasript. Or is there any other way how it can be done?