Skip to content

Instantly share code, notes, and snippets.

@colonelpopcorn
Last active August 13, 2018 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colonelpopcorn/1568ad8a1247cddf6519417288dbfead to your computer and use it in GitHub Desktop.
Save colonelpopcorn/1568ad8a1247cddf6519417288dbfead to your computer and use it in GitHub Desktop.
DotFiles
// ==UserScript==
// @name .chromerc
// @namespace *
// @version 0.1
// @description Utils for debugging
// @author You
// @match *
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.downloadObjectAsJson = function(exportObj, exportName){
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(exportObj));
var downloadAnchorNode = document.createElement('a');
downloadAnchorNode.setAttribute("href", dataStr);
downloadAnchorNode.setAttribute("download", exportName + ".json");
downloadAnchorNode.click();
downloadAnchorNode.remove();
}
// Your code here...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment