Skip to content

Instantly share code, notes, and snippets.

@johnslipper
Created March 28, 2017 06:40
Show Gist options
  • Save johnslipper/713eb94a5996b4667bdf4188919cfc2a to your computer and use it in GitHub Desktop.
Save johnslipper/713eb94a5996b4667bdf4188919cfc2a to your computer and use it in GitHub Desktop.
Console Save Bookmarklet - Allows saving of JS objects to a file
javascript:(console.save=function(e,o){if(!e)return void console.error('Console.save: No data');o||(o='console.json'),'object'==typeof e&&(e=JSON.stringify(e,void 0,4));var n=new Blob([e],{type:'text/json'}),t=document.createEvent('MouseEvents'),a=document.createElement('a');a.download=o,a.href=window.URL.createObjectURL(n),a.dataset.downloadurl=['text/json',a.download,a.href].join(':'),t.initMouseEvent('click',!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),a.dispatchEvent(t)});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment