Welcome guest, is this your first visit? Create Account now to join.
Results 1 to 4 of 4

This is a discussion on Bookmark RSS within the Chrome Plugins section, part of the Google Chrome category: Haven't see this anywhere so I decided to give the bookmarks API a whirl. This is a proof of concept, ...


  1. #1
    proneax is offline Junior Member
    Join Date
    Jun 2009
    Posts
    8

    Default Bookmark RSS

    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>
    Attached Files Attached Files
    Last edited by proneax; 06-09-2009 at 08:52 AM. Reason: clarification

  2. #2
    Chrome's Avatar
    Chrome is offline Administrator
    Join Date
    Sep 2008
    Posts
    345

    Default

    Great work dude. Works like a charm. I am alwasy on the lookout for recent news and all in order to update some of my blogs with and this is pretty usefull..

    Great work.. Would feature it on the blog soon.

    Want to write up this on the blog?

  3. #3
    proneax is offline Junior Member
    Join Date
    Jun 2009
    Posts
    8

    Default

    poking around the chrome issues on google code looks like there are some updates coming to the bookmark api.

    Also I would like to develop this a bit more but I'm not sure how much time I will have.

    I wouldn't want to publicize this and then have it break on the next developer build, with no time for me to update it. So I will keep you posted. If you want to write it as a proof of concept thats fine.

  4. #4
    proneax is offline Junior Member
    Join Date
    Jun 2009
    Posts
    8

    Default

    Sorry, posted an updated version but on some more testing it really doesn't work well yet.

    I'll try again later.
    Last edited by proneax; 06-13-2009 at 07:19 PM.

Similar Threads

  1. Replies: 12
    Last Post: 05-18-2009, 07:47 PM
  2. Bookmark manager
    By TREPE in forum Chrome Plugins
    Replies: 0
    Last Post: 11-15-2008, 10:22 AM
  3. Bookmark problems
    By snadge in forum Chrome Troubleshooting
    Replies: 1
    Last Post: 11-10-2008, 07:08 PM
  4. Bookmark Problem
    By godsholygate in forum Chrome Talk
    Replies: 0
    Last Post: 11-07-2008, 11:31 PM
  5. Bookmark suggestion
    By morales.brisa in forum Chrome Talk
    Replies: 0
    Last Post: 11-02-2008, 02:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •