Hello again,
when trying to export all of your data off of CDO can be quite the hassle especially if you want to migrate the data to another project when you remix it but only to have it fail when there’s no data in it
const link = location.href.match(new RegExp(`(?<=(applab|gamelab)/)[^/]+|^[^/]+(?!/)$`));
const id = link[0];
const path = `/datablock_storage/${id}/`;
const storage = { keys: {}, tables: {} };
(async function Main(type) {
switch (type) {
case "applab":
await getTables();
case "gamelab":
await getKeyValues();
const anchor = document.createElement("a");
anchor.href = URL.createObjectURL(new Blob([JSON.stringify(storage)], {type: "text/json"}));
anchor.download = `${type}_${id}_storage.json`;
document.body.appendChild(anchor);
anchor.click();
document.removeChild(anchor);
break;
default:
throw "storage medium not supported";
}
})(link[1])
async function getKeyValues() {
try {
storage.keys = (await (await fetch(path + "get_key_values")).json());
for(let k in storage.keys) {
storage.keys[k] = JSON.stringify(storage.keys[k])
}
} catch (err) {
throw "unable to complete request: " + err;
}
}
async function getTables() {
let tableNames = (await (await fetch(path + "get_table_names")).json());
for (let name of tableNames) {
try {
storage.tables[name] = (await (await fetch(path + "read_records?table_name=" + name)).json());
} catch (err) {
throw `unable to append table "${name}" with code: ${err}`
}
}
}
all you need to do is be on the project you want to export → inject the code → hit enter → receive all the project data as a json file for later use that’s all i have currently for now if there is interest of being able to migrate data between projects do let me know and i may work on it
for now though i think this will do
best wishes