I've been working with the codes involving GM_getvalue and GM_setValue. I'd like to access data in my server through ajax.
I've been working with the codes involving GM_getvalue and GM_setValue. Stored data can be found in Storage located in Tampermonkey>Dashboard>Script>Storage. However, it could only be seen on one PC. I would like to access the data in my website/server. Are there any suggestions and codes to make it possible? Ajax perhaps?
if($("#name_full").html()){
$("#name_full").submit(function(){
var Fname = $("#firstname").val();
var Sname = $("#surname").val();
GM_setValue("datalogs",GM_getValue("name_full","")+Fname+" "+Sname +"<br/>");
});
}
I expect codes that can help me obtain these data via my website/server. Help :(
localStorage is the kind of browser storage. It means server can't see what data is stored. If you want to send data from localstorage to the server, you should use http request method. You can use GM_xmlhttpRequest method. For example, code can be like this.
jQ(document).on("keyup", "form input", function () {
let value = GM_getValue("name_full","");
GM_xmlhttpRequest({
method: "POST",
url: "http://....",
data: value,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
onload: function(response) {
alert(response);
var json = $.parseJSON(response);
}
});
});