-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpaste-to-upload.user.js
More file actions
33 lines (25 loc) · 1.02 KB
/
paste-to-upload.user.js
File metadata and controls
33 lines (25 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// ==UserScript==
// @name Paste to Upload
// @namespace http://tampermonkey.net/
// @version 1.1.1
// @description Take over the world. Not try, I'm pretty confident in my abilities.
// @author Radvylf, dictator of our world and fairly cool guy
// @match https://chat.stackexchange.com/rooms/*
// @grant none
// ==/UserScript==
(() => {
var input = document.getElementById("input");
input.addEventListener("paste", (info) => {
console.log(info.clipboardData.files);
if (info.clipboardData.files.length != 1 || document.getElementById("upload-file").disabled)
return;
info.preventDefault();
document.getElementById("upload-file").click();
var files = structuredClone(info.clipboardData.files);
setTimeout(() => {
console.log(files);
document.getElementById("filename-input").files = files;
document.querySelector("div.wmd-prompt-dialog input[type=submit]").click();
}, 0);
});
})();