save and load state

This commit is contained in:
2020-01-12 16:19:38 +08:00
parent f1cf32b83a
commit c7f4fe7cc4
7 changed files with 85 additions and 17 deletions

View File

@ -11,4 +11,22 @@ window.onload = function () {
'url': `https://git.jebbs.co/jebbs/data-extracter-extesion`
});
})
document.querySelector('#state-input')
.addEventListener('change', function (...args) {
if (this.files.length == 1) {
var reader = new FileReader();
let fileName = this.files[0].name;
reader.readAsText(this.files[0], "UTF-8");
reader.onload = function (evt) {
var fileString = evt.target.result;
chrome.runtime.sendMessage({
action: ACTION_UPLOAD_STATE,
state: fileString,
name: fileName
}, r => {
if (r) console.log('State sent:', r);
});
}
}
});
}