Last active
August 19, 2017 17:54
-
-
Save mchubby/8058f81ffe229a44c2fa99ae80e79a1c to your computer and use it in GitHub Desktop.
e.b.l.i.e.v.a.js
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
// PreReq: Inject FileSaver.js + jszip.js | |
// note: pages are periodically purged, automatically | |
_xbl._xct.prototype.clear = function () { } | |
zip = JSZip() | |
var unbound_saver = function (blob, filename, resolve_callback) { | |
zip.file(filename, blob) | |
resolve_callback() | |
}; | |
function bind_trailing_args(fn, ...bound_args) { | |
return function(...args) { | |
return fn(...args, ...bound_args); | |
}; | |
} | |
promises = []; | |
//FIXME: need to call these blocks several times due to purging | |
for (var jsonp in _xga.layoutImageManager.layoutImageList) { | |
if (_xga.layoutImageManager.layoutImageList.hasOwnProperty(jsonp)) { | |
var image = _xga.layoutImageManager.layoutImageList[jsonp] | |
imgname = jsonp.replace( /.*\//, ''); | |
for (v = 0; v < image.decryptImage.canvasList.length; v++) { | |
promises.push( | |
new Promise(function(resolve, reject) { | |
bound_saver_fn = bind_trailing_args(unbound_saver, imgname + v + ".png", resolve) | |
image.decryptImage.canvasList[v].toBlob(bound_saver_fn) | |
}) | |
) | |
} | |
} | |
} | |
Promise.all(promises) | |
.then(function() { | |
zip.generateAsync({type:'blob'}) | |
.then(function(content) { | |
saveAs(content, "image_parts.zip") | |
}) | |
}); | |
for (var idx in _xga.page_info) { | |
console.log("Page " + idx) | |
var data = "" | |
var info = _xga.page_info[idx] | |
for (q = 0; q < info.draw_info.length; q++) { | |
if (info.draw_info[q].k == 'c' && info.draw_info[q].u) { | |
data += Array.prototype.map.call(info.draw_info[q].u.match(/.{1,4}/g), function(val) { return String.fromCharCode("0x" + val) }).join(""); | |
} | |
} | |
console.log(data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment