On the repository side, the URLs for Alfresco and Share are known. You can get all the individual parts from SysAdminParams and you can use UrlUtils to have the different parts joined together for you to give a full URL.
As far as I can tell though, these details are only ever held on the Alfresco Repository tier, and are never passed over to Share. All the absolute URLs in Share seem to be generated in the Repo and sent over
One option then is for you to change your webscript to be a repo webscript rather than a share one. That'll give you access to the appropriate beans. Share will proxy Repo webscripts for you, so you can still access it directly in Share as the logged in user. You'll want a URL a bit like /share/proxy/alfresco/my/web/script
to access them.
Otherwise, create a new repo webscript that exposes the useful bits of the SysAdminParams and Share URLs, and have your share webscript fetch it (likely with caching). There are lots of examples of that too to work with.