Skip to content

Instantly share code, notes, and snippets.

@mcrowe
Created December 6, 2011 21:05
Show Gist options
  • Save mcrowe/1440000 to your computer and use it in GitHub Desktop.
Save mcrowe/1440000 to your computer and use it in GitHub Desktop.
Filter Popups
# Do nothing, silently, when window.open is called
window.open = () ->
# Whitelist pop-ups with urls that match this regular expression.
allowableUrls = /addthis|google/
# Save a pristine copy of the window.open method.
aliasWindowOpen = window.open
# Create a new window.open method that is filtered by url.
window.open = (url, name, features) ->
aliasWindowOpen(url, name, features) if url.match(allowableUrls)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment