Help whit script

i want help whit script to can run in OB2, thanks.
Script:

function login() {
    var form = document.querySelector('form#login')
    var submit = document.querySelector('button#submit')
    var data = getFormData(form)
    var client_nonce = 0;
    console.log(data)
    if (data.email && data.password) {
        submit.disabled = true
        var hash = Sha256.hash(data.email + data.password + client_nonce);
        console.log('h', hash)
        while(! hash.startsWith(data.nonce)) {
            client_nonce++;
            hash = Sha256.hash(data.email + data.password + client_nonce);
        }
        form.querySelector('input[name="cnonce"]').value = client_nonce;
        form.submit()
    }
}