javascript – SP Online : hide share/sync and other oob buttons on modern list view command bar

I want to hide the out of the box buttons on list view command bar at root folder level only.

At sub folder level, I want to toggle show/hide buttons based on selected items/folders.

I know we can do it using spfx extension, but not sure where to start to play with out of the box buttons.

Thanks in advance.