Last active
January 18, 2016 09:34
-
-
Save qpSHiNqp/674812398816d9dadf9b to your computer and use it in GitHub Desktop.
Derives a bunch of web page screenshot PNGs from a Chrome Timeline data JSON which can be saved in DevTools > Timeline recordings
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
/** | |
* usage: node screenshotsFromTimeline.js <input timeline data json> | |
* | |
* Derives a bunch of web page screenshot PNGs from a Chrome Timeline data JSON which can be saved in DevTools > Timeline recordings | |
* Runs with node.js | |
*/ | |
var util = require('util'); | |
var fs = require('fs'); | |
function usage() { | |
console.log( | |
util.format("usage: %s %s <inputfile>", | |
process.argv[0], | |
process.argv[1] | |
) | |
); | |
} | |
if (process.argv.length < 3) usage(); | |
var json = fs.readFileSync(process.argv[2]).toString(); | |
var timeline = JSON.parse(json); | |
timeline.forEach(function(entry) { | |
if (entry.name !== "Screenshot") return; | |
var name = entry.ts; | |
var b64 = entry.args.snapshot; | |
var buf = new Buffer(b64, "base64"); | |
fs.writeFile(name + ".png", buf); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment