我想将网站上存在的所有链接添加到新书签文件夹中。有没有脚本可以做到这一点? 示例:在包含美国科学家列表 ( http://en.wikipedia.org/wiki/List_of_American_scientists ) 的维基百科页面中,我想将包含科学家姓名的每个链接添加到名为“美国科学家”的新文件夹中。
谢谢!
最佳答案
您应该考虑为 Chrome 或 Firefox 创建扩展。
然后您可以使用 javascript/jquery 获取 DOM 中的所有链接并添加它们:
$html.find('a').each(function(){
bookmark($(this).attr("title"), $(this).attr("href"));
});
function bookmark(title, href) {
if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(title,href,'');
} else if(window.external && ('AddFavorite' in window.external)) { // IE Favorite
window.external.AddFavorite(href,title);
} else if(window.opera && window.print) { // Opera Hotlist
this.title=title;
return true;
} else { // webkit - safari/chrome
alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'CTRL') + ' + D to bookmark this page.');
}
}
关于javascript - 自动为页面上的链接添加书签的脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27116105/