1 Download the macro file from the link at the end of this page.
2 Import the file into the library panel. See Affinity official documents or refer to other helpful sites.
3 Select the layer and click on the macro you want to run.
*Try the macro "with a fill layer" in the list and switch the visibility of the fill layer that will be created. And you will see what these macros are all about.
*If you want the black/white areas to be completely transparent, make sure that the color of the area is completely black/white before running the macro. You can use the levels adjustment or something.