Created
December 6, 2011 21:05
-
-
Save mcrowe/1440000 to your computer and use it in GitHub Desktop.
Filter Popups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Do nothing, silently, when window.open is called | |
window.open = () -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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