FanFicFare > Configure FanFicFare > Basic tab > Updating Calibre options > Search inside books for story URL.
Then use "overwrite always" when updating and you'll get a FFF ePub.
For some formats (e.g. PDF) you may need to convert to text first or FFF won't be able to grab the URLs.
If the URL is not present in the file you can manually add it to the identifiers as url:
https://archiveofourown.org/works/0000000