GithubHelp home page GithubHelp logo

theawless / drag-to-download Goto Github PK

View Code? Open in Web Editor NEW

This project forked from josephuspaye/drag-to-download

0.0 0.0 0.0 578 KB

๐Ÿ‘‡๐Ÿพ Drag a link from the browser unto your desktop to download.

Home Page: https://chrome.google.com/webstore/detail/drag-to-download/nlbdfajoolkacbicncknldfoikncjdhb

License: MIT License

JavaScript 83.70% HTML 16.30%

drag-to-download's Introduction

Drag to download

๐Ÿ‘‡๐Ÿพ A browser extension that allows you to drag a link from the browser unto your desktop to download.

Animated GIF demonstrating Drag to download

How to use

Install and setup

  • Install the extension: https://chrome.google.com/webstore/detail/drag-to-download/nlbdfajoolkacbicncknldfoikncjdhb.
  • Visit each domain you want to enable the extension on, click the extension icon in the browser toolbar, then click Enable Drag to download on this domain.
  • The browser will prompt you to give the extension permission to access the domain and reload the page. After you accept and reload, you should be able to drag and drop links to download.

Remove from a domain

To remove the extension from a domain, visit the domain, click the extension icon, and then uncheck Enable Drag to download on this domain.

Design

Uses a little-known drag-and-drop feature in Chrome as described in this article. Unfortunately this feature works only in Chrome (tested on Windows).

When a dragstart event is triggered on a link, we attach a DownloadURL property to the event's dataTransfer property. This property's value is of the form mime_type:file_name:absolute_url:

  • omit the mime type (for the browser to determine)
  • compute the file name from the link's download property, href, or inner text
  • compute the download URL by converting the link's href to an absolute URL

In code, this looks like the following (simplified):

linkElement.addEventListener('dragstart', function(e) {
  const { file, url } = getDownloadUrlProperty(e.currentTarget);
  e.dataTransfer.setData('DownloadURL', `:${file}:${url}`);
});

Contributing

See contribution guide.

Licence

MIT

drag-to-download's People

Contributors

dependabot[bot] avatar josephuspaye avatar theawless avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.