Reopen Dexie Database with Tampermonkey

扶醉桌前 提交于 2020-01-06 10:04:12

问题


As per my previous post, I was referred to create a new post. As seen in the comments, there is a trail of progression for the issue, I'll rephrase here in this post:

I'm using a TamperMonkey script in FireFox.

I'm trying to persist a Dexie object/database into TamperMonkey's local storage with GM.setValue('unique-dexie-db-name', dexieDBvariable);

However when I go to retrieve this value (ex. I store this on google.com, and retrieve this on yahoo.com) with var dexieDB = GM.getValue('unique-dexie-db-name'); My returned object value is not a Dexie database object, but rather something else I can't use as a database.

My question: I'm unsure, but I think when storing this Dexie Database into TamperMonkey, it gets stored as a string, and, I should try to somehow JSON.stringify() the object fully in order to be able to reproduce and re-create it when I need it in the GM.getValue() call. How do I store this Javascript object as a string in order to be able to retrieve the value again as a whole later?

This is my working example code;

https://gist.github.com/n-bell/b375c80b638d3a59a250e903afb4a36b.js

https://gist.github.com/n-bell/b375c80b638d3a59a250e903afb4a36b

(second link looks better formatted in browser)

And, as stated before, I've tried playing around with JSON.parse() / JSON.stringify() but I'm not sure this is the path to go down.

来源:https://stackoverflow.com/questions/57938009/reopen-dexie-database-with-tampermonkey

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!