Skip to content

Instantly share code, notes, and snippets.

@salsalabs
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salsalabs/c432ff97757da78afa16 to your computer and use it in GitHub Desktop.
Save salsalabs/c432ff97757da78afa16 to your computer and use it in GitHub Desktop.
Script to change the ZIP code prompt on a targeted action. Use this script to make little changes or to replace the whole thing.
<script type="text/javascript">
// See https://help.salsasupport.com/entries/64867194-Change-the-ZIP-code-prompt-for-targeted-actions
document.addEventListener( "DOMContentLoaded", function(){
if (!RegExp('public.+action_KEY=\\d+').test(window.location.href)) {
return;
}
var waiter = null;
var handler = function() {
var target = document.getElementById('postalCodeForm');
if (target != null) {
target.innerHTML = '' + 'In order to address your MESSAGE to the appropriate recipient, we need to identify where you are.<br/>'
+ 'Please <a href="https://tools.usps.com/go/ZipLookupAction!input.action" target="_blank">lookup</a> '
+ 'and use your full nine-digit zip for the best results.' + '<br/>' + 'Please enter your zip/POSTAL code: '
+ '<input id="tempPostalCode"'
+ ' onkeypress="if (event.keyCode == 13){submitPostalCode();return false;}else{return true;}"'
+ ' size="5"></input>'
+ '<input type="button" value="Submit" onclick="return submitPostalCode();return false;"></input>'
+ '<br></br>';
if (waiter != null) {
clearInterval(waiter);
waiter = null;
}
$('input[value=Submit]').val('Submit');
}
}
handler();
waiter = setInterval(handler, 200);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment