Created
December 14, 2008 00:36
-
-
Save javascripter/35587 to your computer and use it in GitHub Desktop.
This file contains 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
// ==UserScript== | |
// @name FastLDR | |
// @namespace http://d.hatena.ne.jp/javascripter/ | |
// @include http://fastladder.com/reader/ | |
// ==/UserScript== | |
var native_post = unsafeWindow.API.prototype.post; | |
var api_key = null; | |
GM_xmlhttpRequest({ | |
method: "GET", | |
url: "http://reader.livedoor.com/reader/", | |
onload: function (res) { | |
var m = res.responseText.match(/^var ApiKey = "(.*)";/m); | |
if (m) { | |
api_key = m[1]; | |
} else { | |
unsafeWindow.message("API key not found.(Please login to LDR)"); | |
} | |
} | |
}); | |
unsafeWindow.API.prototype.post = function(param, onload){ | |
if (/^\/api\/config\//.test(this.ap)) { | |
return native_post.apply(this, arguments); | |
} | |
var onload = onload || this.onload; | |
var oncomplete = this.onComplete; | |
if (typeof onload != "function") { | |
onload = function() {}; | |
} | |
param.ApiKey = api_key; | |
setTimeout(GM_xmlhttpRequest, 0, { | |
method: "post", | |
url: "http://reader.livedoor.com/" + this.ap, | |
data: unsafeWindow.Object.toQuery(param), | |
headers: { "Content-Type" : "application/x-www-form-urlencoded" }, | |
onload: function(res) { | |
oncomplete(); | |
unsafeWindow.API.last_response = res.responseText; | |
var json = unsafeWindow.JSON.parse(res.responseText); | |
if (json) { | |
onload(json); | |
} else { | |
unsafeWindow.message("can't load data"); | |
unsafeWindow.show_error(); | |
} | |
} | |
}); | |
this.onCreate(); | |
return this; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment