Skip to content

Instantly share code, notes, and snippets.

@jnwelzel
Last active August 11, 2017 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jnwelzel/811bac4dee11c369e005 to your computer and use it in GitHub Desktop.
Save jnwelzel/811bac4dee11c369e005 to your computer and use it in GitHub Desktop.
Injection
//generate the javascript content of method cloudpassSetUsername to inject into the current page
function injectSetUsernameFunc(usernameFieldIsId,usernameField){
var js = 'window.cloudpassSetUsername = function(username){';
if(usernameFieldIsId){
js += 'forceChangeField( document.getElementById("'+usernameField+'"), username);';
}else{
js += 'forceChangeField( document.getElementsByName("'+usernameField+'")[0], username);';
}
js += '};';
return js;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment