I found this method console.save (data, [filename]), which you can add to the console, which handles the trick easily. Note that when a file is downloaded, it simply goes directly to the default download folder. To add it, just run:
(function(console){ console.save = function(data, filename){ if(!data) { console.error('Console.save: No data') return; } if(!filename) filename = 'console.json' if(typeof data === "object"){ data = JSON.stringify(data, undefined, 4) } var blob = new Blob([data], {type: 'text/json'}), e = document.createEvent('MouseEvents'), a = document.createElement('a') a.download = filename a.href = window.URL.createObjectURL(blob) a.dataset.downloadurl = ['text/json', a.download, a.href].join(':') e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null) a.dispatchEvent(e) } })(console)
Then pass the data and file name like this: console.save (data, [filename]), and the file will be created and uploaded.
A source:
https://plus.google.com/+AddyOsmani/posts/jBS8CiNTESM
http://bgrins.imtqy.com/devtools-snippets/#console-save
source share