Skip to content

For developers

Send downloads to Download Manager Plus from any website, with a link or with JavaScript.

“Add to Download Manager Plus” button

A link styled as a button. It works without JavaScript; with the helper script, it uses the bridge when it's available.

HTML
<a
  class="dmplus-button"
  href="https://download.extension.lat/add?name=manual.pdf&url=https%3A%2F%2Fexample.com%2Ffiles%2Fmanual.pdf"
  data-dmplus-url="https://example.com/files/manual.pdf"
  data-dmplus-name="manual.pdf"
  rel="nofollow"
>
  Add to Download Manager Plus
</a>

<style>
  .dmplus-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 999px;
    background: #a3e635;
    color: #1a2e05;
    font: 600 0.875rem/1 system-ui, sans-serif;
    text-decoration: none;
  }
  .dmplus-button:focus-visible {
    outline: 2px solid #1a2e05;
    outline-offset: 2px;
  }
</style>

Helper script

A small, dependency-free script that exposes window.DownloadManagerPlus. The TypeScript types are in dmplus.d.ts.

HTML
<script src="https://download.extension.lat/sdk/dmplus.js" defer></script>

<!-- Optional: links with data-dmplus-url use the bridge. -->
<script src="https://download.extension.lat/sdk/dmplus.js" data-dmplus-auto defer></script>

Add data-dmplus-auto to the script tag so links with data-dmplus-url use the bridge. Don't do this on pages that show links written by your users: on a trusted site, the bridge downloads without asking.

JavaScript
// Uses the bridge if it's available on your site; otherwise, opens the universal link.
const result = await window.DownloadManagerPlus.addDownload({
  url: "https://example.com/files/manual.pdf",
  name: "manual.pdf",
});

if ("requestId" in result) {
  const state = await window.DownloadManagerPlus.bridge.status(result.requestId);
  console.log(state.status); // "pending", "downloading", "complete"…
}

JavaScript bridge

If the user lets websites send them downloads (the welcome guide offers this for every site) or allows your site from the extension icon, your page can request downloads and check their status with window.postMessage. The user still confirms each download, unless they mark your site (https) as trusted.

Messages
NameDescription
dmplus:addRequests a download: url, plus optional fileName and folder.
dmplus:statusChecks the status of a download your own page requested.
dmplus:resultThe extension's reply, with the same id you sent.
dmplus:readyThe extension announces that the bridge is active on the page.
dmplus:pingAsks whether the bridge is active; the extension replies with dmplus:ready.
JavaScript
// Without the helper script: the same protocol with postMessage.
window.addEventListener("message", (event) => {
  if (event.source !== window) return;
  if (event.data?.source === "dmplus-extension" && event.data.type === "dmplus:result") {
    console.log(event.data.id, event.data.result);
  }
});

window.postMessage(
  {
    id: crypto.randomUUID(),
    request: { url: "https://example.com/files/manual.pdf", fileName: "manual.pdf", v: 1 },
    source: "dmplus",
    type: "dmplus:add",
  },
  location.origin
);

Reference

Statuses

Statuses
NameDescription
pendingWaiting for the user to confirm the download.
rejectedThe user declined it or closed the window.
downloadingDownloading.
completeDownload finished.
failedThe download couldn't be completed.

Error codes

Error codes
NameDescription
invalid-requestMalformed message, an address that isn't http(s) or a local network address.
unsupported-versionYour page uses a newer protocol version than the extension.
rate-limitedMore than 10 requests per minute from your site.
too-many-pendingRequests are already waiting for confirmation.
not-foundThat ID doesn't exist or wasn't requested by your page.
internalInternal error; try again.

Limits and privacy

Only http(s) addresses are accepted, with no custom headers or cookies. Each site can make up to 10 requests per minute and only receives the status of the downloads it requested. A public site can't request files from the user's local network.