我想在自定义面板中刷新信息。
但在观看面板时,onShown 无法刷新。我怎样才能或...必须在 onShow 中使用 setInterval()?
清单.json:
{
"name": "sample",
"version": "0.1",
"manifest_version": 2,
"devtools_page": "devtools.html"
}
开发工具.html:
<html><body><script src="devtools.js"></script></body></html>
开发工具.js:
var view_counts = 0;
chrome.devtools.panels.create(
"sample", "sample.png", "sample.html",
function(panel){
panel.onShown.addListener(function(panel_window){
panel_window.document.getElementById("show_count").innerHTML = view_counts;
// and moer update.
});
}
);
chrome.devtools.network.onRequestFinished.addListener(
function(entries) {
if(entries.request.url == "http://example.com/"){
view_counts++;
// and more analytics
}
}
);
示例.html:
<html><body>count: <div id="show_count">-</div></body></html>