Index

Functions

downloadUrl

  • downloadUrl(url: string, saveAs: boolean): Promise<void>
  • Download a given URL to disk

    Normal URLs are downloaded normally. Data URLs are handled more carefully as it's not allowed in WebExt land to just call downloads.download() on them

    Parameters

    • url: string

      the URL to download

    • saveAs: boolean

      prompt user for a filename

    Returns Promise<void>

downloadUrlAs

  • downloadUrlAs(url: string, saveAs: string, overwrite: boolean, cleanup: boolean): Promise<unknown>
  • Dowload a given URL to disk

    This behaves mostly like downloadUrl, except that this function will use the native messenger in order to move the file to saveAs.

    Note: this requires a native messenger >=0.1.9. Make sure to nativegate for this.

    Parameters

    • url: string
    • saveAs: string

      If beginning with a slash, this is the absolute path the document should be moved to. If the first character of the string is a tilda, it will be expanded to an absolute path to the user's home directory. If saveAs begins with any other character, it will be considered a path relative to where the native messenger binary is located (e.g. "$HOME/.local/share/tridactyl" on linux).

    • overwrite: boolean
    • cleanup: boolean

    Returns Promise<unknown>

objectUrlFromDataUrl

  • objectUrlFromDataUrl(dataUrl: URL): string
  • Construct an object URL string from a given data URL

    This is needed because feeding a data URL directly to downloads.download() causes "Error: Access denied for URL"

    Parameters

    • dataUrl: URL

      the URL to make an object URL from

    Returns string

    object URL that can be fed to the downloads API