【发布时间】:2015-07-22 11:18:10
【问题描述】:
我想监听选项卡中发生的所有时间线事件, 我创建了一个扩展
chrome.browserAction.onClicked.addListener(function(tab) {
var tabId = tab.id;
console.log("tabId = ", tabId);
if (running === false) {
checkAvailable();
chrome.debugger.attach({
tabId: tabId
}, protocolVersion, function() {
running = true;
if (chrome.runtime.lastError) {
console.log(chrome.runtime.lastError.message);
return;
}
chrome.debugger.sendCommand({
tabId: tabId
}, "Tracing.start", { "maxCallStackDepth" : 5 }, function(response) {
console.log(response);
// listening for responses from Timeline
chrome.debugger.onEvent.addListener(function(tabId, method, params) {
console.log("params = ", params);
});
});
chrome.debugger.onDetach.addListener(function (source, reason) {
running = false;
});
});
} else {
chrome.debugger.detach({
tabId: tabId
}, null);
running = false;
}
});
单击图标后,我可以在页面顶部看到黄色条,并且消息是“扩展正在调试此页面”。
但是,在 F5 之后,我没有看到我的扩展程序侦听时间线事件。
似乎尚未分配事件。
chrome.debugger.onEvent.addListener(function(tabId, method, params) {
console.log("params = ", params);
});
有什么想法吗?
【问题讨论】:
标签: google-chrome google-chrome-extension