I want to be able to add websites to a chrome extension options page. So I have a text box with a "save" button and I want to be able to save multiple websites with the ability to edit or remove them later. Like this:
Enter URL: |_________| |_save_|
Edit Remove - www.google.com
Edit Remove - www.msn.com
Edit Remove - www.yahoo.com
Once you enter a website and click save, it will add it to the list of websites already there. I've been trying to scavenge the internet to try to figure out how to accomplish this, but I just don't know enough about it to complete it.
I'd recommend
chrome.storage
instead oflocalStorage
: http://developer.chrome.com/extensions/storage.htmlIt's fantastic. You can even choose to store data online in your Google profile (100KB max). Otherwise offline (100MB max, I think).
API is super simple too:
Unlike
localStorage
, it's async, so you'll be using callbacks. But it's lightning fast, so the UI won't notice.What I'd do is not keep a virtual record of your storage, but keep it in HTML and read from/write to that as necessary:
http://jsfiddle.net/rudiedirkx/Zbpmx/
I'm assuming jQuery since it's popular. It's not necessary of course.
If you're having problems with this already, a Chrome extension will be insanely difficult.