-
This adds a button to the bottom of the page to fix the 'lack of user activation protection' error in the Inspect Element console. Additionally, this will overwrite the current environment where you're running it, so please be careful.
let loadSaveButton = document.createElement('button'); loadSaveButton.id = 'loadSaveButton'; loadSaveButton.innerText = 'Load Save'; document.body.appendChild(loadSaveButton); loadSaveButton.addEventListener('click', () => { if (confirm("WARNING: There is a chance this may delete your save!!")) { let input = document.createElement("input"); input.type = "file"; input.onchange = e => { let fileReader = new FileReader(); fileReader.onload = async e => { try { let res = JSON.parse(e.target.result); let session = res?.["!session"]; let localSaves = res?.trainer1; let parsedSaves = JSON.parse(localSaves); if (!(session || localSaves)) return alert("Doesn't look like a valid save file!"); for (let key in res) await localforage.setItem(key, JSON.parse(res[key])); alert(`Done! Loaded ${parsedSaves.length} local saves!`); location.reload(); } catch (error) { alert("Error parsing the save file. Please ensure it's a valid format."); } }; fileReader.readAsText(e.target.files[0]); }; input.click(); } });
Please register or sign in to comment