Just make a custom one that passes in the current page or a document id, then use the api to get the count and return the integer. Should be a pretty simple implementationm, just make sure you follow the documentation on creating a custom macro and create your class and register it correctly, otherwise you won't be able to access it from the macro editor.