I am new to Javascript and trying to write a script in tampermonkey to create a button that generates emails on getnada.com
The problem is when you want to create a new email the webpage shows a random combination of username and domain, and I wrote a script that changes the value of the username to a string and the value of the domain to a specific domain, and they do change but when I create the email the webpage creates it according to the values that it showed in the first place not the values that my code entered. here is my script:
// ==UserScript==
// @name test
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://getnada.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
'use strict';
function randStr(len) {
let s = '';
while (s.length < len) s += Math.random().toString(36).substr(2, len - s.length);
return s;
}
let btn = document.createElement("button");
btn.innerHTML = "Click Me";
document.body.appendChild(btn);
btn.onclick = function () {
document.getElementsByClassName("mt-4 bg-white text-gray-800 active:bg-gray-100 text-xs font-bold uppercase px-4 py-2 rounded shadow hover:shadow-md outline-none focus:outline-none lg:mr-1 lg:mb-0 mb-3")[0].click();
var delayInMilliseconds = 1
setTimeout(function() {
document.querySelector("#grid-first-name").value = randStr(10);
document.querySelector("#__layout > div > div > div.container.mx-auto.px-4.mb-20 > nav > div.fixed.inset-0.w-full.h-screen.flex.items-center.justify-center.bg-smoke-800.z-50 > div > div > div > form > div > div.inline-block.relative.w-64 > select").value="getnada.com"
}, delayInMilliseconds);
}
})();
now what am I doing wrong and how to fix it?