Skip to content

Instantly share code, notes, and snippets.

@saschanaz
Last active October 20, 2018 05:37
Show Gist options
  • Save saschanaz/293f9c7698776c8f3510aff703209d24 to your computer and use it in GitHub Desktop.
Save saschanaz/293f9c7698776c8f3510aff703209d24 to your computer and use it in GitHub Desktop.
DataTransafer.files polyfill
// ==UserScript==
// @name DataTransfer files polyfill
// @namespace http://saschanaz.github.io/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://pawoo.net/web/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
if (new DataTransfer().files) {
return;
}
Object.defineProperty(DataTransfer.prototype, "files", {
get() {
return [...this.items]
.filter(item => item.kind === "file")
.map(item => item.getAsFile())
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment