【问题标题】:How do I send my history to a server from a google extension如何将我的历史记录从 google 扩展程序发送到服务器
【发布时间】:2017-10-25 10:47:35
【问题描述】:

我正在尝试使用我的 google 扩展程序记录我的浏览器历史记录并使用 AJAX 将其发送到我的服务器。这可能吗?如果是这样,怎么做?我正在尝试使用我为个人使用而创建的谷歌扩展来做到这一点。

【问题讨论】:

标签: ajax google-chrome google-chrome-extension


【解决方案1】:

您可以使用chrome.history获取浏览历史记录:

使用 chrome.history API 与浏览器的访问页面记录进行交互。您可以添加、删除和查询浏览器历史记录中的 URL。

然后在发送的时候,就可以使用AJAX从chrome扩展向服务器发送数据了。

来自相关SO post的代码片段:

//bind to all links
$('a').click( function() {
   //get the url
   var url = $(this).prop('href');
   //send the url to your server
   $.ajax({
        type: "POST",
        url: "http://yourserver.com/process.php",
        data: "url=" + url
   });
});

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多