简体   繁体   English

如何将数据从chrome扩展发送到localhost?

[英]How can i send data from chrome extension to localhost?

I am creating a google chrome extension to read my History of browser. 我正在创建一个谷歌浏览器扩展程序来阅读我的浏览器历史记录。 All works done. 所有工作完成。 Now i am willing to send the retrieved history data to my localhost server . 现在我愿意将检索的历史数据发送到我的localhost服务器 Is this possible? 这可能吗? How to do this? 这个怎么做? Please anyone help me. 请有人帮帮我。

Thanks in advance. 提前致谢。

Simply post your data to localhost server. 只需将您的数据发布到localhost服务器即可。

Just remember to add permission in manifest.json. 只需记住在manifest.json中添加权限。

{
    "manifest_version": 1,      
    "name": "Your Extension",
    ...

    "permissions": [
        ....
        "http://localhost:1234/"
    ]
}

Second version would be via app network in Chrome https://developer.chrome.com/apps/app_network 第二个版本将通过Chrome中的应用网络https://developer.chrome.com/apps/app_network

But this requires more low level programming. 但这需要更低级别的编程。

The basic steps (sample code contained in the following links) would be: 基本步骤(以下链接中包含的示例代码)将是:

  1. Add your local server url to permissions field in manifest.json 将本地服务器URL添加到manifest.json permissions字段
  2. Use Ajax , Websocket , Nativemessaging (You would need nativeMessaging permission instead), or any other communication method to exchange data between extension and your local server. 使用AjaxWebsocketNativemessaging (您需要使用nativeMessaging权限)或任何其他通信方法在扩展和本地服务器之间交换数据。

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

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