Skip to content

Instantly share code, notes, and snippets.

@rushkeldon
Created February 23, 2026 00:47
Show Gist options
  • Select an option

  • Save rushkeldon/c6d14eb658a2aa045cdcf313453c4d51 to your computer and use it in GitHub Desktop.

Select an option

Save rushkeldon/c6d14eb658a2aa045cdcf313453c4d51 to your computer and use it in GitHub Desktop.
function whenDOMready(func ) {
switch ((document.readyState + "")) {
case "complete":
case "loaded":
case "interactive":
func();
break;
default:
window.addEventListener("DOMContentLoaded", (e) => func());
}
}
function checkUsername() {
const form = document.querySelector('form');
if( !form ) return Boolean( console.log( 'checkUsername : form not found' ) );
const input = form.querySelector('input[type="text"]');
if( !input ) return Boolean( console.log( 'checkUsername : input not found' ) );
if( !input.value ) return Boolean( console.log( 'checkUsername : input has no value' ) );
return true;
}
function clickNext() {
const form = document.querySelector('form');
if( !form ) return Boolean( console.log( 'clickNext : form not found' ) );
const btn = form.querySelector('input[type="submit"]');
if( !btn ) return Boolean( console.log( 'clickNext : btn not found' ) );
btn.click();
return true;
}
whenDOMready( () => {
window.setTimeout( () => {
checkUsername() && clickNext() && console.log( 'successfully clicked the Next btn.' );
}, 200 );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment