Download this file and save to your Obsidian Vault including the first line, or open it in “Raw” and copy the entire contents to Obsidian.
This script expands the height of the selected rectangles until they are all the same height and keep the text centered.