title: Chrom Extension: onDeterminingFilenme interfers with all downloads
body: <p>I'm coding an extension that downloads items with specific names. Currently, I have two types of items to download:</p>
  <ul>
  <li>Items that have the link to the file URL, so it can be directly downloaded and its name determined by <code>chrome.downloads.download</code> (type A)</li>
  <li>Items that don't have the link to the file URL, and had to be downloaded via a direct download link. The download process has to be initiated separately and its file name changed with <code>chrome.downloads.onDeterminingFilename.addListener</code> (type B)</li>
  </ul>
  <p>The problem is <code>chrome.downloads.onDeterminingFilename.addListener</code> interfere with all downloads regardless of the parameters set. I want it only to change the filename when the type B item is downloaded.</p>
  <p>Basic rundown of my code</p>
  <pre><code>chrome.downloads.download({ //type A items
        url: item.imageLink, //set linkURL
        filename: setName //set name
      });
  //item will be downloaded with *setName*
  chrome.downloads.onDeterminingFilename.addListener((downloadItem, suggest) =&gt; { //type B items
  //item will be intercepted, its name being its original filename
    if (item != null &amp;&amp; item.type == &quot;B&quot; &amp;&amp; downloadItem.url == item.imageLink) { //check linkURL
      suggest({filename: setName, conflictAction: &quot;uniquify&quot;}); //item's filename will be changed to *setName*
    }  
  });
  </code></pre>
  <p>Unless I remove the <code>chrome.downloads.onDeterminingFilename</code> completely, the file downloaded will be its original filename regardless of what type it is.</p>
  <p>I thought of 3 possible solutions:</p>
  <ol>
  <li>Brute force the <code>chrome.downloads.onDeterminingFilename</code>, make it change the name of every item downloaded.</li>
  </ol>
  <ul>
  <li>Problem: it'll mess up other downloads, including those from other extensions</li>
  </ul>
  <ol start="2">
  <li>Remove <code>chrome.downloads.onDeterminingFilename</code> when it's not type B items, and add it in when it is.</li>
  </ol>
  <ul>
  <li>Problem: no guarantee when it will be removed to not interfere with other items being downloaded simultaneously when it's running</li>
  </ul>
  <ol start="3">
  <li>Figure out how to download type B items without using <code>chrome.downloads.onDeterminingFilename</code></li>
  </ol>
  <ul>
  <li>Problem: I've tried it, I've found nothing on converting direct download links to fileURLs, especially if the direct download link is generated uniquely</li>
  </ul>
  <p>Any other suggestions or am I doing this all wrong?</p>