Created
May 31, 2011 16:36
-
-
Save fuba/1000836 to your computer and use it in GitHub Desktop.
dotjs-ify my greasemonkey user scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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