在chrome扩展程序中捕获文件上传/下载事件?

时间:2019-02-18 10:49:28

标签: javascript api google-chrome google-chrome-extension request

要捕获使用chrome扩展名的下载事件,我可以在background.js中使用事件chrome.downloads.onCreate ..我可以举一个示例,在文档中找不到示例吗?

另外,要捕获上载事件,正如我在此处阅读的,Is there any reliable way to capture file upload event in a chrome extension?

我可以使用chrome.webRequest.onBeforeRequest事件,但是如何使用?任何代码示例都将非常有帮助...

我通过捕获onChange Event的输入[type ='file']设法从DOM捕获了上载事件,但这不是很有效。我需要捕获Web请求并在那里检查文件是否存在。

谢谢

var slctList = document.querySelectorAll("input[type='file']");
for(i=0;i<slctList.length;i++){

    slctList[i].addEventListener("change", function(){
               var files = e.files;
               var file = files[0];
               console.log(file.name);

            });
}

0 个答案:

没有答案