我正在創建一個chrome擴展,用於監控下載進度。我能夠捕獲下載開始並下載完整的事件,但不知道如何獲得改變的進度?請幫忙。 下面是我的下載聽衆我如何在Chrome擴展中捕獲下載進度
function AddDownloadListener() {
//--------------------------------------------------------------------------------------------------------------
chrome.downloads.onCreated.addListener(DownloadCreated);
chrome.downloads.onChanged.addListener(DownloadChanged);
function DownloadCreated(el) {
console.log("Download Begins");
console.log(el);
mobjPortToFoxtrot.postMessage({ message: "Download Begins", element: el });
}
//--------------------------------------------------------------------------------------------------------------
function DownloadChanged(el) {
if (el.danger === undefined || el.danger == null) {
console.log(el.state.current);
mobjPortToFoxtrot.postMessage({ message: el.state.current, element: el });
}
else {
console.log("dangerous content");
mobjPortToFoxtrot.postMessage({ message: "dangerous content", element: el });
}
console.log(el);
}
}
你必須輪詢下載狀態。 – 2014-10-03 13:32:18
@RobW:任何類似的東西的參考?我如何進行民意調查呢? – 2014-10-03 13:34:56