Custom Names for Post Formats in Gutenberg, Not Working

For a website I have implemented Post Formats as a way to indicate how a post should be formatted on the homepage. It’s an easy way to assign class name and style it with CSS. This way an editor can easily appoint a post as featured or as a post without featured image, thus making the title bolder to compensate.

With the classic editor I was able to assign the Post Formats custom names.

Script to assign Post Formats custom names in Classic Editor

This worked beautifully without any issues. That is until we switched over to Gutenberg (Block Editor). I was able to find only one solution to change the names, but that solution for some reason I am not able to figure – does not work.

Script to assign Post Formats custom names in Gutenberg

I searched through Google and the WordPress forum. So far I have not been able to figure out a solution.

This is part 2 of Transitioning from Classic Editor to Gutenberg Editor