【问题标题】:transfer data from winforms to chrome via chrome extension通过 chrome 扩展将数据从 winforms 传输到 chrome
【发布时间】:2014-10-01 18:49:00
【问题描述】:

我有一个 c# 中的 windows 应用程序,在其中我通过 chrome 扩展获取在 chrome 中打开的页面的 Html 这就是我编写 chrome 扩展的方式

background.js

chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {

if (changeInfo.status === 'complete') {
    chrome.tabs.executeScript(tabId, { file: "jquery.min.js" }, function () {
        chrome.tabs.executeScript(tabId, { file: "content.js" }, function () {
            chrome.tabs.sendMessage(tabId, { text: tab }, function (data) {
                alert("hi");
                chrome.tabs.getAllInWindow(data.WindowId, function (response) {                        
                    for (var i = 0; i < response.length; i++) {
                        if ((response[i].index + 1) == data.Tab) {
                            chrome.tabs.update(response[i].id, { selected: true });
                        }
                    }
                });
            });
        });
    });
}

});

Content.js

chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {

$.post(listener, { dom: document.all[0].outerHTML }, function (data) {

});

});

现在我需要在 winform 中有一个按钮来向 chrome 发送一些数据。请帮忙。

【问题讨论】:

    标签: winforms google-chrome


    【解决方案1】:

    知道了,我们可以使用原生消息应用通过原生应用消息与 chrome 进行交互

    https://developer.chrome.com/extensions/messaging#native-messaging

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-18
      • 1970-01-01
      • 2014-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多