Discussions » Development

Greasemoneky GM_xmlhttpRequest POST

§
Posted: 2016/07/29

Greasemoneky GM_xmlhttpRequest POST


I am trying to create a script that will send a POST requests immediately after loading the web page .

The POST data parameter will contain certain values that it will collect from element in responseHTML via "document.getElementsByName"

here is what i am doing but it isnt working ---

var id1 = document.getElementsByName("ID1")[0].value

var id2 = document.getElementsByName("ID2")[0].value

GM_xmlhttpRequest({method: "POST",
url: "https://www.example.com/",
data: 'paramter1=' + id1 '¶mter2=' + id2 ,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
onload: function(response) {
console.log ("gut response");
$("#input").get()[0].value=response.responseText;
}
});

woxxomMod
§
Posted: 2016/07/29

Typo: paramter

§
Posted: 2016/07/29

xmlhttpRequest works only on same domain I think.
Are you pushing your script in a page from example.com?

§
Posted: 2016/07/29
Edited: 2016/07/29

For reference, the code indented and as a code block:

var id1 = document.getElementsByName("ID1")[0].value

var id2 = document.getElementsByName("ID2")[0].value

GM_xmlhttpRequest({
    method: "POST",
    url: "https://www.example.com/",
    data: 'paramter1=' + id1 '&paramter2=' + id2,
    headers: {
        "Content-Type": "application/x-www-form-urlencoded"
    },
    onload: function(response) {
        console.log("gut response");
        $("#input").get()[0].value = response.responseText;
    }
});
§
Posted: 2016/07/30

I assume you don't see any obvious errors in the console?

Try adding an onerror handler to see whether you get any insight that way.

Post reply

Sign in to post a reply.