2020-02-04 22:05:29 +01:00
|
|
|
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) {
|
2020-02-04 22:05:29 +01:00
|
|
|
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);
|
2020-02-04 22:05:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default IO;
|