Search code examples
javascriptdatabasegreasemonkeyuserscripts

Store and retrieve data online using a userscript


i want to be able to store and retrieve data online using a username and a password so a userscript that runs on a webpage can have personalized information.For example i want to write notes for users in a forum and want to retrieve them from any computer that my userscript is installed.

I thought google spreadsheets would do the trick but i havent been able to implement it. I also have thought of using something like persistencejs https://github.com/zefhemel/persistencejs/blob/master/docs/sync.md or http://www.sencha.com/products/io/ but neither of them are simple enough for the knowledge on programming i have.

So is there a simple way of doing this?


Solution

  • there is no easy way to do this, you have to store data in your server and create a connection between your server and userscript.

    here is how you can do that,

    • create a login box in your userscript, so users can login.

    • get username and password and send it your server page with GM_xmlhttpRequest. chrome and firefox support cross domain xhr with GM_xmlhttpRequest, so you will not have problem about that if you are writing that script for firefox or google chrome.

    • in your server page get username and password and check them for matching in your database, than create json response that contains data for matched user.

    • get response of request in your userscript and do what you want.