Skip to content

Instantly share code, notes, and snippets.

@sakinijino
Last active August 29, 2015 14:20
Show Gist options
  • Save sakinijino/3cdbaadaa595f64236b4 to your computer and use it in GitHub Desktop.
Save sakinijino/3cdbaadaa595f64236b4 to your computer and use it in GitHub Desktop.
(function (){
function getContent(cb){
function getAsin(cb){
var title = $("#KindleReaderIFrame")[0].contentWindow.document.getElementById("kindleReader_title").innerHTML;
KindleDBClient.getAppDb().getTable('bookdata').getRecord({title:title}).done(function(e){cb(e[0].asin)});
};
function getF(asin, cb){
var bookdb =$("#KindleReaderIFrame")[0].contentWindow.KindleReaderBookInfoProviderDB.BookInfoDB(asin);
bookdb.getFragmentIds().done(function(e){
bookdb.getFragments(e).done(cb);
})
};
function getMD(asin, cb){KindleDBClient.getBookDb().getTable("bookinfo").getRecord({asin:asin}).done(function(e){cb(e[0].metadata)})};
getAsin(function(asin){
getF(asin, function(fragments){
getMD(asin, function(md){
var kc = $("#KindleReaderIFrame")[0].contentWindow.KindleCompression;
c = {};
kc.lzAddStringsToDictionary(md.cpr, c);
kc.lzAddNumbersToDictionary(c);
d = kc.lzGetDecompressionDictionary(c);
content = "";
for (var i=0; i<fragments.length; ++i)
if (fragments[i]) content += kc.lzExpandWithStaticDictionary(fragments[i].fragmentData, d, 256);
cb(content);
})})})
};
getContent(function(c){document.body.innerHTML = c});
})();
@sakinijino
Copy link
Author

老代码,可能已经不能用了,留底,说明见:http://sakinijino.com/archives/4022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment