I tried to recreate the enchantment table mechanics or how the enchantment table randomly selects enchantments basic on certain instructions found in this Wiki. I am using the latest stable 1.12.0-beta.1.21.0-stable, but this works in stable also, since I created this in stable first, and then just reupdated the code to work in latest version 1.12.0.
It consists of this javascript files: