如何在Chrome扩展程序中使用历史记录API获取浏览记录 [英] How to get browsing history using history API in Chrome extension

查看:746
本文介绍了如何在Chrome扩展程序中使用历史记录API获取浏览记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用chrome.history API获取最近访问过的标签的URL,特别是访问过的最后10个URL?

How can I get the URLs of recently visited tabs using chrome.history API, specifically, the last 10 URLs visited?

推荐答案

将一个空字符串作为查询传递给chrome.history API的 search()方法。例如,这会将最近访问的10个URL记录到控制台:

Pass an empty string as your query to the search() method of the chrome.history API. For example, this will log the 10 most recently visited URLs to the console:

chrome.history.search({text: '', maxResults: 10}, function(data) {
    data.forEach(function(page) {
        console.log(page.url);
    });
});

这篇关于如何在Chrome扩展程序中使用历史记录API获取浏览记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆