Private Eye

Made by 18F. Available on GitHub.

A JavaScript plugin to warn users about links to private pages. Places a :lock: icon next to any links with any URLs that you specify as private, and gives a warning message.

At 18F, this is used on public sites that contain links to internal content like private GitHub repositories or Google Docs. Rather than write two versions to redact those links, this allows us to publish new content and give a warning to both staff and external readers.

Use ignoreUrls to supply all the private URLs. Any link that matches one of the URLs will have a lock icon next to it.

Demo

This private link should not have a lock.

Cat ipsum dolor sit amet, lick the other cats. Plan steps for world domination a private link while this is a public link on your pillow rainbow while flying in a toasted bread costume in space.

This one should.

Cat ipsum dolor sit amet, lick the other cats. Plan steps for world domination a private link, a private link with MiXedCaSe while this is a public link on your pillow rainbow while flying in a toasted bread costume in space.

Code

<script src="private-eye.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
  PrivateEye({
    // list of URLs to match as substrings – can be full URLs, hostnames, etc.
    ignoreUrls: [
      'http://so.me/private/url',
      'anoth.er',
      // ...
    ]
  });
}, false );
</script>