ngld / OverlayPlugin

Yet another OverlayPlugin fork.
Other
231 stars 39 forks source link

Download of files disabled in built-in Chromium? #246

Open ghost opened 2 years ago

ghost commented 2 years ago

Is download of files disabled in the current chromium version used by OverlayPlugin? I tried creating a link and simulating a click with click() to download a stringified object but it looks like it doesn't work (no errors in console). I can import/read files just fine by simulating click() on an input tag though.

Example:

    const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(settings));
    const link = document.createElement("a");
    link.setAttribute("href", dataStr);
    link.setAttribute("download", "settings.json");
    e.target.parentElement.appendChild(link);
    link.click();
    e.target.parentElement.removeChild(link)
ghost commented 2 years ago

I tested the method both in Firefox and Chromium 101.0.4921.0 (Developer Build) (64-bit) but it appears it's not usable with the built-in version used by the plugin.

image

ngld commented 2 years ago

Downloads have to be implemented (since it's part of Chromium's UI and OverlayPlugin replaces the UI). I'd have to figure out where to save the download, maybe ask the user whether the download is desired and once that's done, perform the download (maybe show download progress) and notify the user that the download is done.

It's a rare use case so I probably won't work on this but I'd accept a PR that does this (though we should probably discuss details like the download prompt, notification, etc. first). As a workaround, you could write the data to the user's clipboard instead.