javascriptgoogle-chromegoogle-chrome-extensiongoogle-chrome-appchrome-app-developer-tool

Google chrome api javascript detect file open in browser


For google chrome extension i need to be able to detect if user use chrome browse to open .html file.

I tried different method but it seem i do not get an event

"permissions": ["webRequest","browsingData", "fileSystemProvider"],
  "file_system_provider_capabilities": {
       "configurable": true,
       "watchable": true,
       "source": "file"
},

I tried to intercept in webRequest

chrome.webRequest.onBeforeSendHeaders.addListener(function(info){
// info.url does not give me the file.html which opened


)};

I tried with different methods for file event handling but none get fire

    chrome.fileSystemProvider.onOpenFileRequested.addListener(function(file){
    console.log("open file");
});
chrome.fileSystemProvider.onReadFileRequested.addListener(function(file){
    console.log("read file");
});
chrome.fileSystemProvider.onExecuteActionRequested.addListener(function(){
    console.log("execute file");
});

Thanks in advance for any help


Solution

  • Much thank you for wOxxOm to give me a hint. What I currently have in my permission is ":///". I need to include "file://*" in the permission. I thought the *: should be good enough but not in this case. So right now I am be able to see file:// protocol in chrome.webRequest.onBeforeRequest