Last active
October 20, 2018 05:37
-
-
Save saschanaz/293f9c7698776c8f3510aff703209d24 to your computer and use it in GitHub Desktop.
DataTransafer.files polyfill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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