Closed misslivirose closed 7 months ago
Hmm, it seems that the three ways to save have different requirements:
saveAsPDF
(silent mode): Runs your custom FF code. It requires a preceding slash to save to correct directory (as per this PR).saveAsPDF
(non-silent mode): Automatically converts slashes to underscores, so we omit the subdirectory prefix all together.saveHtml
(with browser.downloads.download
): Disallows the preceding slash because it's interpreted as an absolute path.So I recommend changing only the silent-mode saveAsPDF
path (instead of DOWNLOAD_SUBDIRECTORY
):
async function savePDF() {
try {
await browser.tabs.saveAsPDF({
- toFileName: `${DOWNLOAD_SUBDIRECTORY}/PAGE${generateFileName("pdf")}`,
+ toFileName: `/${DOWNLOAD_SUBDIRECTORY}/PAGE${generateFileName("pdf")}`,
silentMode: true, // silentMode requires a custom build of Firefox
});
} catch (_e) {
Otherwise, the saveHtml
path breaks:
Previously, the extension would create a DownloadsMemoryCache folder instead of Downloads/MemoryCache. This fixed it, but I'm not sure if there's a better way.