Any sort of "sanitisation" of arbitrary JavaScript is doomed to fail, but there's Caja project which defines a subset of JavaScript and DOM that can be analyzed statically, and can reject suspicious scripts (and unfortunately also benign scripts when it can't fully understand them).
A better approach may be to simply to execute JavaScript as-is, but on a separate domain. This way your site will be protected by same-origin policy, the same way browsers protect all sites from each other.
You'll need a completely separate TLD if you use cookies (since a script on any subdomain can poison cookies on the entire domain). That's the approach Google takes with googleusercontent.com that's used to run arbitrary scripted pages for Google Translate, etc.
When you run JS on a separate domain, via an iframe, you'll need to use postMessage to communicate between your page and the untrusted script. Make sure you carefully validate the messages you receive, as you would any user input or an API call.