ultrawidify/src/common/js/IO.ts

25 lines
731 B
TypeScript
Raw Normal View History

class IO {
2020-02-04 23:14:48 +01:00
/**
* Export a (presumably json) string to file. Meant for use with content script.
* @param {*} jsonString string to be saved
*/
static async csStringToFile(jsonString) {
console.info("\n\n\n\n---------- Starting export of log to file ----------------");
console.info("[info] json string for exportObject:", jsonString.length);
const blob = new Blob([jsonString], {type: 'application/json'});
const fileUrl = URL.createObjectURL(blob);
2020-02-04 23:14:48 +01:00
const a = document.createElement('a');
a.style.display = 'none';
a.href = fileUrl;
2020-02-06 22:59:43 +01:00
a.download = 'ultrawidify-log.log';
2020-02-04 23:14:48 +01:00
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(fileUrl);
}
}
export default IO;