【发布时间】: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 发送一些数据。请帮忙。
【问题讨论】: