I'm writing a Greasemonkey script that will run when the user visits a page, collect some information on the page, then send that info to another location for logging. However whenever the script hits the call to GM_xmlhttpRequest it just halts. For example:
// ==UserScript==
// @name GetProfileInfo
// @namespace LinkedIn
// @include https://www.linkedin.com/profile/view*
// @version 1
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
console.log("start");
GM_xmlhttpRequest({
method: "GET",
url: "http://www.google.com",
onload: function(response) {
console.log("sent");
}
});
console.log("done");
Outputs just "start".
I thought I might have to to @grant GM_xmlhttpRequest in the head but when I do that, there is no output at all!
UPDATE: So it seems I do want to @grant GM_xmlhttpRequest but when I do I get the error "Components.utils.getObjectPrincipal is not a function"
You miss @grant GM_xmlhttpRequest
// @grant GM_xmlhttpRequest
The result: start done sent