Summary
- Create the extension you want.
- Have the user you want to port your extension to create a some extension using "Describe an Extension".
- Copy the contents of the extension in the following directory, give it to the user, and delete and replace the contents of the extension they created.
~/Library/Containers/com.apple.Safari/Data/Library/Safari/MagicExtensions/
Detailed
The directory where extensions created using Safari's "Describe an Extension" are stored.
~/Library/Containers/com.apple.Safari/Data/Library/Safari/MagicExtensions/
You should find a folder named "Your extension name - random string" within this directory. The contents of this folder are the extension's main files. (There should basically be three files: manifest.json, content.js, and content.css.)
Actually, manifest.json, content.js, and content.css can be freely edited. As long as you edit them grammatically correctly, Safari won't care at all. In fact, if you add other JS or CSS files and write the manifest correctly to load those files, those additional JS and CSS files will also work.
So I thought, "Maybe I can share the extensions I create with other people?"
I immediately tested it. Since I also have Safari Technology Preview installed, I tried putting an extension I created using regular Safari into the directory in STP where extensions created using "Describe an Extension" are stored.
~/Library/Containers/com.apple.SafariTechnologyPreview/Data/Library/SafariTechnologyPreview/MagicExtensions/
However, it didn't work. I suspected that the extensions that Safari should load were registered in a database within this folder, or perhaps in a database located elsewhere.
So, I created a simple extension using STP (with instructions like "make this page's background black") and replaced its contents with the files of an advanced extension I had created in Safari. BOOM! The name and icon remained the same as the one created in STP, but the contents had been completely replaced with those of the Safari extension. It works perfectly.
Since you can change the extension's name and icon later, if you're concerned about it, you can simply modify the name and icon.
This shows that it's possible to share extensions with other people.
If you'd like to try it
This is an extension I actually use that forces the use of system fonts (.AppleSystemUIFont) for pages with simply set fonts to font-family:sans-serif; or font-family:serif;. (For example, Google search results page.)
Don't worry, you can check the contents beforehand, and you can even ask a suitable AI if this code is safe.
Simply replace the three items mentioned above with the contents of the extension directory that you have Safari create for you.
Please feel free to ask if you have any questions.