It can be done in snippets sure, a snippet can do everything a regular extension can, except that it can’t contain any extra files. A quick example:
#popclip
name: Safari Only
required apps: [com.apple.Safari, com.apple.SafariTechnologyPreview]
javascript: popclip.showText("Hello Safari!")