This particular case doesn't use JavaScript at all. It is just CSS cropping the full URL in a way that when you select and copy it, copies text that it is hidden.
edit to add an example:
data:text/html,<div>123<b style="font-size:0">456</b>789</div>