Haven't see this anywhere so I decided to give the bookmarks API a whirl.
This is a proof of concept, if you install it it will create a folder in your Bookmarks bar and populate it with links from a Reuters RSS feed.
Until you can store user data I don't see an elegant way of storing custom RSS feeds other than hand editing the file.
RSS feed is piped through google feeds api for convenience. Also from my understanding of the 'permissions' requirement that will soon be implemented, you have to specify what sites your extension can contact anyway, so piping through google makes life easier, but limits updates to ~1hr.
Button in the toolstrip updates the RSS feed.
Extension is attached (rename to .crx and drag into browser). Code below. This was just for fun, don't expect any updates, feel free to modify repost etc.
HTML Code:<html> <head> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> var bk = chrome.bookmarks; var glob_pid = ''; google.load("feeds", "1"); function deleteBookmarks() { bk.get([glob_pid], function(tree) { bk.get(tree[0].childrenIds, function(results) { for (var i = 0; i < results.length; i++) { bk.remove({ 'id': results[i].id, 'recursive': true }, function() { }); } }); }); } function set_e(entry,idx,pid){ bk.create({ 'parentId': pid, 'index': idx, 'title': entry.title, 'url': entry.link },function (){ }); } function initialize() { bk.search('--End of Feed--', function (res) { if(res.length){ glob_pid=res[0].parentId; deleteBookmarks(); } else{ bk.getChildren(1, function(result) { bk.create({ 'parentId': 1, 'index': result.length, 'title': 'rss temp' },function (result){ glob_pid = result.id; }); }); } }); var feed = new google.feeds.Feed("http://feeds.reuters.com/reuters/topNews?format=xml"); feedlen=10; feed.setNumEntries(feedlen); feed.load(function(result) { if (!result.error) { for (var i = 0; i < feedlen; i++) { var entry = result.feed.entries[i]; set_e(entry,i,glob_pid); } var addendum = " --End of Feed-- "+result.feed.title; bk.create({ 'parentId': glob_pid, 'index': feedlen, 'title': addendum, 'url': result.feed.link },function (){ return true; }); bk.setTitle({ 'id': glob_pid, 'title': result.feed.title },function(result) { }); } else{ document.write("<p>"+result.error+"</p>"); } }); } google.setOnLoadCallback(initialize); </script> </head> <body> <div class="toolstrip-button" onclick="initialize();"> <span>Update RSS</span> </div> </body> </html>


LinkBack URL
About LinkBacks



Reply With Quote
