i'm trying to build a browser extension that reads the "users online counter" on a specific website. I then want my browser extension so send this number to my server (i have my own top domain). I want this number to be saved in an number.html file on the server. I did some research and think that this can be done with a XMLHttpRequest POST request, but i am a beginner in coding and can't get it to work.
xhttp.open("POST", "www.mydomain.com/number.html", false);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(numbervariable);
Or do i need to point that request to a .php file on my server, that can process the request and save the incoming number in a .html file? I would really appreciate some help what code i need in my browser extension and what needs to be done on my server to process the incoming data. Maybe a .php file like this?
$html=base64_decode(urldecode($_POST['innerHTML']));
file_put_contents(numbers, $html);
I am completely lost...