Friday, 16 October 2009

More iPredict My Portfolio tweaks - adding persistent Notes field

Following on from my previous hacks, I've made another addition to my Greasemonkey script to modify iPredict's My Portfolio page, this time inspired by a forum post by ORACLE.

He requested that iPredict should add an editable Notes column to the portfolio. I've wanted this feature myself, so I figured this would be a good time to experiment with DOM Storage, since this allows local persistence of data like this, without requiring support from the server.

My updated script now adds a 'Notes' column next to each line in the portfolio, which lets you enter freeform text which is stored permanently (in your Firefox local user profile) for when you come back to the page.

The DOM Storage API for globalStorage seems to work fine in Greasemonkey (in Firefox 3.0.14), providing you tunnel through the Greasemonkey wrapper using 'wrappedJSObject' to access the globalStorage object, like this:
window.wrappedJSObject.globalStorage[window.location.hostname].setItem(key, noteText)
(I've used the older, non-standard globalStorage object, rather than the HTML5-standardized localStorage, because I'm still running FF3.0 which doesn't implement localStorage; when I eventually switch to 3.5 I may change it.)

As before, to get the script, download the current ipredict-portfolio.js from my repository on github here, and install in Greasemonkey - then just use iPredict as normal and enjoy the new stuff. See the previous post for more info.

No comments:

Post a Comment