Closed JeromeDeLeon closed 2 years ago
Hello,
Sure, this sounds like a useful feature to have. I will make sure to add it in the next update.
In the meantime, because I don't know yet when the next update will be, let me offer you a code snippet that might make your life easier:
(function(generator, direction) {
chrome.storage.local.get({custom_generators: null}, function(data) {
if (!data.custom_generators) {
console.error('Failed to read data properly', data);
return;
}
if (['up', 'down'].indexOf(direction) < 0) {
console.error('Direction can be only "up" or "down"');
return;
}
let pos = data.custom_generators.findIndex(function(gen) {
return gen.label == generator;
});
if (pos < 0) {
console.error('Generator "' + generator + '" not found');
return;
}
if (pos == 0 && direction == 'up') {
console.error('Generator already on first position');
return;
}
if (pos == data.custom_generators.length-1 && direction == 'down') {
console.error('Generator already on last position');
return;
}
var new_pos = pos + (direction == 'down' ? 1 : -1);
data.custom_generators.splice(new_pos, 0, data.custom_generators.splice(pos, 1)[0]);
chrome.storage.local.set({custom_generators: data.custom_generators}, () => {window.location.reload()});
});
})('generator_name', 'direction');
Open Fake Data's options page, then open the browser's console and run the above code. Make sure to replace on the last line the generator_name
with the name of your custom generator and direction
with either up
or down
.
If executed successfully, the page will reload and the generator selected should be moved either up or down.
P.S.: Make a backup of your generators first. You know... just in case
This is so useful. Thanks for this. I'll try it when I can later
Hello,
In the latest version of Fake Data (v.4.0.0) you can now reorder custom generators.
Is there a way we could add sorting of generators? I find it weird to have my generators to be in different order and that I have to move them manually through deletion/creation
Thank you