简体   繁体   English

如何获得Chrome书签树的所有末端节点?

[英]How to get all the end nodes of chrome bookmark tree?

I have been trying get all the bookmarked urls in chorme to the extension i am making. 我一直在尝试将所有加标签的网址添加到我正在做的扩展程序中。 But till now i have only managed to get the tree, and its a very lengthy task to check where all the folders are and getting urls from them. 但是到目前为止,我只设法得到了这棵树,这是一个非常漫长的任务,要检查所有文件夹在哪里并从中获取URL。 Is there any method using which i can get all the end nodes (which would be urls) all together? 有什么方法可以让我将所有末端节点(可能是网址)放在一起? I am using mootools framework. 我正在使用mootools框架。

This is how I would approach it: 这就是我的处理方式:

function collectLinks( bookmark , bag )
{ 
  if( bookmark.children)
  { 
    for(var i = 0; i < bookmark.children.length ; i++ ) 
      collectLinks( bookmark.children[i] , bag ) 
  } 
  if(bookmark.url)bag.push(bookmark) 
}

This function iterates over a bookmark node ad infinitum 此功能可无限遍历书签节点广告

var list = [];
chrome.bookmarks.getTree( function(bookmarks){ collectLinks( bookmarks[0] , list ); collectLinks( bookmarks[1] , list );} )

This will get the bookmarks and retrieve the URLs into 'list'. 这将获取书签并将URL检索到“列表”中。 On a side note, bookmarks[0] is the bookmark bar, bookmarks[1] is the 'other bookmarks' 在旁注中, bookmarks[0]是书签栏, bookmarks[1]是“其他书签”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM