0

Is There A Browser-Add-on That Can Create A Temporary Txt File From My Clipboard And Populate The File Submit Dialog?

Noitidart
  • 35,443
  • 37
  • 154
  • 323
del bao
  • 1,084
  • 1
  • 11
  • 20
  • 1
    I can help you make this for firefox very easily. If you would like to learn jump onto irc my name is noida: `irc://moznet/extdev` (paste to your firefox browser) or if you dont have an irc client here is an online html client: https://client00.chat.mibbit.com/?url=irc%3A%2F%2Firc.mozilla.org%2F%extdev – Noitidart Aug 31 '15 at 02:45

1 Answers1

0

Guide for firefox:

Get the data from your clipboard with this: paste data from clipboard using document.execCommand("paste"); within firefox extension

Now you can either create a temporary file with something like OS.File: https://developer.mozilla.org/en-US/docs/JavaScript_OS.File/OS.File_for_the_main_thread

Or create a object with something like window.createObjectUrl.

Then assuming the file submit dialog is prompted by a html5 uploader, then you should just set value of that html5 dialog box there are other ways though too, like mozSetDataAt, mozSetFileArray etc, search github for these keywords shows excellent examples:

You might need to use the mimeType of application/x-moz-file not sure. Definitely experiement with it and share your solution, and ask for help along the way. This is fun stuff.

There are probably other smarter ways to attach into a input type=file, i was trying to do it the other week. I would also be interested if someone else could share some solutions to actually trick the file input element to think the native file dialog was actually used, maybe using XPCOM.

Community
  • 1
  • 1
Noitidart
  • 35,443
  • 37
  • 154
  • 323