Skip to content

Instantly share code, notes, and snippets.

@phated
Last active August 19, 2021 20:10
Show Gist options
  • Save phated/6cc52ad8e598e7570181d15198e0eaae to your computer and use it in GitHub Desktop.
Save phated/6cc52ad8e598e7570181d15198e0eaae to your computer and use it in GitHub Desktop.
Dark Forest Map Export
function exportMap() {
// This requires the React Devtools to be installed in your browser.
// Download them from https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en
// And then make sure to close your inspector & reload the Dark Forest client
// It seems like React Devtools has a hard time starting up, so try all the "reboot" tricks you can think of
// Once you do all of the above, make sure to load up the game, and copy-paste this script into your developer tools console
let container = document.querySelector('[class^=AppContainer] > div > div');
__REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent.selectNode(container);
let fiberID = __REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent.getIDForNode(container);
__REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent.storeAsGlobal({ id: fiberID, path: ['props', 'children', 'props', 'value'], rendererID: 1, count: 1 });
let chunks = $reactTemp1.getExploredChunks();
let chunksAsArray = Array.from(chunks);
copy(chunksAsArray);
console.log("Your map (also, copied to clipboard):", chunksAsArray);
}
exportMap();
function importMap() {
// This script will allow you to import another map that was exported by the `exportMap` function
// Due to the size of the map data, you will need to insert this script into your devtools console
// But before running it, you need to copy the map data into your clipboard and then hit Enter to run the script
// It also relies on the `clipboard` API which requires focus on the game for it to work,
// so you need to click into the game within 2.5 seconds of running this
// The map should uncover instantly, but there will be a delay on the persisting it to storage.
// Once it has been persisted, you will need to refresh before you can interact with any of the new planets, etc.
let container = document.querySelector('[class^=AppContainer] > div > div');
__REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent.selectNode(container);
let fiberID = __REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent.getIDForNode(container);
__REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent.storeAsGlobal({ id: fiberID, path: ['props', 'children', 'props', 'value'], rendererID: 1, count: 1 });
let addChunk = (chunk) => $reactTemp1.gameManager.localStorageManager.updateChunk(chunk);
console.log("Please focus the game so we can request access to your clipboard");
setTimeout(async () => {
let text = await window.navigator.clipboard.readText();
let chunks = JSON.parse(text);
chunks.forEach(addChunk);
console.log("Loaded map into memory, waiting for it to be saved to disk... (this will take a long time)");
}, 2500);
}
importMap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment