Last active
August 13, 2018 14:53
-
-
Save colonelpopcorn/1568ad8a1247cddf6519417288dbfead to your computer and use it in GitHub Desktop.
DotFiles
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
// ==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