Originally published at omerbinsaleem.com by Omer Bin Saleem (Omer Saleem).
Some web apps build their file input only at the moment you click, so an agent's upload tool finds nothing to fill. A small patch to one browser method gives it a target.
How to do it
- Look at the page before you automate it. LinkedIn's post composer keeps no file input in the DOM. It creates one when you press 'Choose file' and calls click() on it, which opens the system file picker, and an agent can't drive that dialog.
- Patch HTMLInputElement.prototype.click before you press the button. When the input being clicked is a file input, attach it to the page instead of opening the picker. Let every other input click as normal.
- Press 'Choose file' the way a person would. The app builds its input and calls click(), your patch catches the call, and the input now sits in the page where the agent can see it.
- Point the agent's file_upload tool at that input with your file path. That is how a 10-page PDF document post went up, and LinkedIn showed 'Post successful'. The upload tool takes at most 10 MB per call, so compress large files first.
- Keep a person on the last click. Show the caption and the first comment as a preview, and post only after an explicit yes.
Prompt to copy
In the open tab, the upload button creates its file input only when clicked, so there is nothing to fill yet. Before you press it, run JavaScript that wraps HTMLInputElement.prototype.click: if this.type is 'file', append the input to document.body and return without opening the picker; otherwise call the original click. Then press the upload button, find the new file input, and use the file upload tool on it with [FILE PATH]. Check that the file shows in the composer. Do not post. Show me the caption and the preview, and wait for my yes.
I am Omer Bin Saleem, a frontend chapter lead who builds with AI every day. One practical AI hack a day at omerbinsaleem.com. LinkedIn: omer-bin-saleem ยท Instagram: @iomerbinsaleem.
Written with AI assistance, from my own work notes.
Top comments (0)