Hello!
Here is a seed of "gimpfu.py" for Gimp 2.99.6. It comes with a test plugin "Add a mask and invert" which just inverts the colors of the selected layer and adds a white mask to it.
Installation : Put the "addAMaskAndInvert" directory (It contains "gimpfu.py") into the "plug-in" directory.
(The test is accessible by "Filters -> Development -> Tests -> Add a mask and invert".)
This is given with no warranties at all.
Hope this helps!

Here is a seed of "gimpfu.py" for Gimp 2.99.6. It comes with a test plugin "Add a mask and invert" which just inverts the colors of the selected layer and adds a white mask to it.
Installation : Put the "addAMaskAndInvert" directory (It contains "gimpfu.py") into the "plug-in" directory.
(The test is accessible by "Filters -> Development -> Tests -> Add a mask and invert".)
This is given with no warranties at all.
Hope this helps!