Ok so, I created a bookmarklet to open up a website and log in for me. I got it to work, but it only works if I hold `Ctrl` when I click the bookmark. can anyone help me fix the issue so that it will work even if I don't hold `Ctrl`?

```
window.location.assign("https://www.thewebsiteiwant.com");
window.onload=doThis;
function doThis(){
    document.getElementsByName("username")[0].value="username";
    document.getElementsByName("password")[0].value="password";
    var inputs = document.getElementsByTagName("input");
    for(var i = 0;i < inputs.length; i++){
        if(inputs[i].type === "submit"){
            inputs[i].form.submit();
        }
    }
}

```

EDIT:

and yes, I do know that saving my username/password in a bookmark is a huge security issue, but if a hacker got into my work computer, the last thing they'll go for is my login for a page containing un-useful information.

EDIT2:

GOT IT TO WORK, Thanks @DG for helping me brainstorm:

```
javascript:
var sitexyz = "https://www.thewebsiteiwant.com";
if(document.URL == sitexyz){
    document.getElementsByName("username")[0].value="username";
    document.getElementsByName("password")[0].value="password";
    var inputs = document.getElementsByTagName("input");
    for(var i = 0;i < inputs.length; i++){
        if(inputs[i].type === "submit"){
            inputs[i].form.submit();
        }
    }
} else {
    window.location.assign(sitexyz);
    window.onload=doThis;
    function doThis(){
        document.getElementsByName("username")[0].value="username";
        document.getElementsByName("password")[0].value="password";
        var inputs = document.getElementsByTagName("input");
        for(var i = 0;i < inputs.length; i++){
            if(inputs[i].type === "submit"){
                inputs[i].form.submit();
            }
        }
    }
}

```