如何通过 GM 用户脚本登录 neopets.com

How to login to neopets.com through GM userscript

我创建了一个从 Neopets login page 开始并自动填充用户名和密码的用户脚本。我无法让脚本点击巨大的绿色“登录”按钮。

$('input[name=username']).val('username_here');
$('input[name=password']).val('password_here');

我已经尝试了以下所有方法来单击登录按钮或提交表单。

//None of these clicked the sign in button:
$("input.submit[name = 'welcomeLoginButton']").submit();
$("input.submit[name = 'welcomeLoginButton']").click();
$('body').on('click','welcomeLoginButton',function(){alert('logged in?');});
new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.submit[name = 'welcomeLoginButton']"))).click();

我知道没有名为 'welcomeLoginButton' 的元素,只有一个名为 .welcomeLoginButton 的 class。填写用户名和密码后如何让表单自行提交?

只需获取带有 class welcomeLoginButton 的所有元素的列表,然后单击第 0 个索引。

jQuery版本:

$('.welcomeLoginButton')[0].click();

普通 JS 版本:

document.getElementsByClassName("welcomeLoginButton")[0].click();
// querySelector without the All just returns the first index of the array
document.querySelector('.welcomeLoginButton').click();
document.querySelectorAll('.welcomeLoginButton')[0].click();