Staredit Network

Staredit Network -> Computers and Technical -> Greasemonkey
Report, edit, etc...Posted by Doodle77(MM) on 2007-02-04 at 12:06:57
How would I make/replace a unprivileged function using Greasemonkey?
For example, I want to be able to have the following function be called by an onclick of a button, if i just declare it in the greasemonkey script, it obviously doesn't work, and it also doesn't work if i put it in script tags and insert it.
Here's the function:
CODE

function makeRequest(url,method,postdata) {
   var http_request = false;
   http_request = new XMLHttpRequest();
   if (http_request.overrideMimeType) {
       http_request.overrideMimeType('text/plain');
       // See note below about this line
   }
   http_request.onreadystatechange = function() {
     if (http_request.readyState == 4) {
       if (http_request.status == 200) {
           document.getElementById('shoutarea').innerHTML = http_request.responseText;
       } else {
           alert('There was a problem with the request.');
       }
     }
   };
   http_request.open(method, url, true);
   http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
   http_request.send(postdata);
}


Locked, solved elsewhere.
Next Page (1)