Skip to content

[BUG] GM_download not work in Safari #2608

@zhuozhiyongde

Description

@zhuozhiyongde

Actual Behavior

I wrote a script trying to download an mp4 file using GM_download. However, it fails in Safari with different behaviors depending on the Download Mode setting:

  1. Mode: Browser API

    • It immediately fails with onerror.
    • Error: not_succeeded.
    • There is no detail field, only an id.
    • Network Analysis: The request initiator is Tampermonkey Extension. It does not send Cookies, causing the download to fail (likely due to server authentication requirements).
  2. Mode: Native

    • The download behaves "normally" regarding the network request.
    • After the download finishes, the onload callback is triggered.
    • Issue: The file is not saved to my Downloads folder.
  3. Mode: Default

    • The download behaves "normally" regarding the network request.
    • After the download finishes, the onerror callback is triggered.
    • Error: Out of memory.
    • There is no detail field, only an id.

Network Analysis for Native/Default in Safari:
The request initiator is WebKit Networking. These requests do carry Cookies, so the download happens successfully (triggering onprogress), but they fail to save the resulting mp4 file correctly.

Use case note: Previously, the "Browser API" mode worked fine. I suspect the backend recently changed to enforce Cookies, though I cannot prove this.

Comparison with Chrome (Arc Browser):

  • Mode: Default: Works perfectly. Request initiator is Browser Helper (with Cookies).
  • Mode: Native: Works perfectly. First, a "Save As" dialog appears, then it downloads. onprogress works, initiator is Browser Helper (with Cookies).
  • Mode: Browser API: Behavior is inconsistent/weird:
    • 1st Attempt: onprogress is NOT called. Initiator is Browser Helper (with Cookies). After download, a specific save dialog appears.
    • Refresh & 2nd Attempt: A save dialog appears first, then downloading starts. onprogress is called normally. Initiator is Browser Helper (with Cookies). Download works.

Expected Behavior

GM_download should consistently download the file and save it to the disk across all modes in Safari, ensuring Cookies are included in the request if the script context allows it, just as it does in Chrome. Specifically:

  1. "Browser API" mode in Safari should include Cookies.
  2. "Native" mode in Safari should save the file to the disk upon completion.
  3. "Default" mode should not throw an "Out of memory" error.

Steps to reproduce the issue

  1. Create a script using GM_download to download a large file (e.g., mp4) from a server that requires Cookies/Authentication.
  2. Open Safari.
  3. Go to Tampermonkey Settings -> General -> Downloads BETA -> Download Mode.
  4. Test with 'Browser API', 'Native', and 'Default'.
  5. Observe the errors described above (No Cookie/Not Succeeded, File not saved, or Out of Memory).

Screenshots or Screencasts

N/A

Environment (please complete the following information)

  • Browser and Version:
    • Safari: Version 26.1 (20622.2.11.119.1)
    • Arc (Chrome): Chromium Engine Version 139.0.7258.128
  • Tampermonkey version:
    • Safari: Version 5.4.6229(6229)
    • Arc: 5.4.0
  • Operating System and Version: macOS 15.7.2 (24G325)

Script

See here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions