exporting prompts. see #65
This commit is contained in:
parent
4d9329ae22
commit
d003b8f0d3
1 changed files with 16 additions and 3 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getPrompts, setDefaultPromptsProperties, setCustomPrompts } from "../js/mzta-prompts.js";
|
import { getPrompts, setDefaultPromptsProperties, setCustomPrompts, preparePromptsForExport } from "../js/mzta-prompts.js";
|
||||||
|
|
||||||
var promptsList = null;
|
var promptsList = null;
|
||||||
var somethingChanged = false;
|
var somethingChanged = false;
|
||||||
|
|
@ -375,8 +375,21 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
exportPrompts();
|
exportPrompts();
|
||||||
});
|
});
|
||||||
|
|
||||||
function exportPrompts() {
|
async function exportPrompts() {
|
||||||
alert("test export all");
|
const manifest = browser.runtime.getManifest();
|
||||||
|
const addonVersion = manifest.version;
|
||||||
|
const outputPrompts = preparePromptsForExport(await getPrompts());
|
||||||
|
let outputObj = {id: 'thunderai-prompts', addon_version: addonVersion, prompts: outputPrompts};
|
||||||
|
const blob = new Blob([JSON.stringify(outputObj, null, 2)], {
|
||||||
|
type: "application/json",
|
||||||
|
});
|
||||||
|
const currentDate = new Date();
|
||||||
|
const time_stamp = `${currentDate.getFullYear()}${String(currentDate.getMonth() + 1).padStart(2, '0')}${String(currentDate.getDate()).padStart(2, '0')}${String(currentDate.getHours()).padStart(2, '0')}${String(currentDate.getMinutes()).padStart(2, '0')}${String(currentDate.getSeconds()).padStart(2, '0')}`;
|
||||||
|
messenger.downloads.download({
|
||||||
|
url: URL.createObjectURL(blob),
|
||||||
|
filename: `thunderai-prompts-${time_stamp}.json`,
|
||||||
|
saveAs: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const btnImport = document.getElementById('btnImport');
|
const btnImport = document.getElementById('btnImport');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue