代码之家  ›  专栏  ›  技术社区  ›  user332951

Google chrome api javascript检测浏览器中打开的文件

  •  1
  • user332951  · 技术社区  · 6 年前

    对于google chrome扩展,我需要能够检测用户是否使用chrome browse打开。html文件。

    我尝试了不同的方法,但似乎我没有得到一个事件

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

    我试图拦截webRequest

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

    我尝试了不同的文件事件处理方法,但没有一种方法会引发火灾

        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");
    });
    

    提前感谢您的帮助

    1 回复  |  直到 6 年前
        1
  •  1
  •   user332951    6 年前

    非常感谢wOxxOm给我一个提示。我目前的权限是“ :// /“。我需要在权限中包含“file://*”。我认为*:应该足够好,但在这种情况下不行。所以现在我可以在chrome.webRequest.onBeforeRequest中看到file://protocol

    推荐文章