使用chrome.downloads.download,是否可以使文件不弹出下载栏?

Using chrome.downloads.download, is it possible to make the file not popup the download bar?

当我执行chrome.downloads.download时,它下载文件并弹出底部的下载栏并显示它,我可以抑制它吗?

示例:

/* some code to suppress download bar */

chrome.downloads.download(
  { "url": request.ImageToDownload },
  function (downloadId){
    // ...
  }
);

是的,这是可能的。你可以 fully suppress the download bar:

chrome.downloads.setShelfEnabled(boolean enabled)

Enable or disable the gray shelf at the bottom of every window associated with the current browser profile. The shelf will be disabled as long as at least one extension has disabled it. Enabling the shelf while at least one other extension has disabled it will return an error through runtime.lastError. Requires the "downloads.shelf" permission in addition to the "downloads" permission.

确保在完成后恢复它。此功能的想法是让您构建一个自定义 UI 来替换货架。