I'm trying to put a GreaseMonkey script together (with jQuery support) that gathers a little information on a user, that's stored on a subdomain. I finally got it working, after a long while, and rather than 'querying' 60 things each time I refresh the same page (with every page you visit you 'query', on average, another 60 new users), I want to use localStorage to relieve the load on the server (especially as it's not mine. Not planning on making this code public so I should be fine).
Now, I'm using
var current = {};
current.profile = profile;
current.name = $(data).find('.userName').text();
localStorage.setItem('userInfo', JSON.stringify(current));
This simply overwrites the userinfo with the latest profile it queries, let's say profile: 1234 and name: Mave. I want to be able to store new entries as they come, possibly a date so when it's older than 30 days, retrieve them again, and load them from localStorage when they exist.
I've thought of using
current[profile].profile = profile;
current[profile].name= $(data).find('.userName').text();
but it doesn't even work because it doesn't support array fields in that way, I suppose. Any pointers?