How to create a “plugin” or “block” that can manipulate WordPress DOM in frontend?

How to create a “plugin” or “block” that can manipulate WordPress DOM in frontend?