That has exponential complexity, is network-bound (slow) and still doesn't handle many cases (for example a "current DOM" where all relative links and images are broken).
Also not sure why you'd want to share a link to a page where all the images and links are broken in the first place.