Skip to content

Instantly share code, notes, and snippets.

@fuba
Created May 31, 2011 16:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fuba/1000836 to your computer and use it in GitHub Desktop.
Save fuba/1000836 to your computer and use it in GitHub Desktop.
dotjs-ify my greasemonkey user scripts
function GM_getValue (key) {
var value = localStorage.getItem('GM_'.key);
if ('undefined' == typeof(value)) {
return;
}
return value;
}
function GM_setValue (key, value) {
localStorage.setItem('GM_'.key, value);
return value;
}
function GM_log (logs) {
console.log(logs);
}
function GM_registerMenuCommand () {
// IMPREMENT ME
return;
}
function GM_xmlhttpRequest (args) {
var xhr = new XMLHttpRequest();
xhr.open(args.method, args.url, true);
if (args.overrideMimeType) xhr.overrideMimeType(args.overrideMimeType);
xhr.onreadystatechange = function (aEvt) {
if (xhr.readyState == 4) {
if(xhr.status == 200) {
if (args.onload) args.onload(xhr);
}
else {
if (args.onerror) args.onerror(xhr);
}
}
};
xhr.send(null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment