What I have in here is a page manipulation through Safari using Javascript.
set eshopwedropUrlDialog to display dialog "Eshopwedrop Item URL" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue"
set eshopwedropPriceDialog to display dialog "Price" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue"
set eshopwedropUrl to text returned of eshopwedropUrlDialog
set eshopwedropPrice to text returned of eshopwedropPriceDialog
tell application "Safari"
make new document with properties {URL:eshopwedropUrl}
activate
set jq to do shell script "curl https://code.jquery.com/jquery-latest.min.js"
do JavaScript "$('.customs-banner').hide();" in document 1
do JavaScript "$('#dg_no').click();" in document 1
do JavaScript "$('#address_id').val('23118').change()" in document 1
do JavaScript "$('#prices_0_price').val('" & eshopwedropPrice & "')" in document 1
do JavaScript "$('#lion_upload_btn').click()" in document 1
end tell/
tell application "System Events"
keystroke "G" using {command down, shift down}
delay 1
keystroke "~/Downloads/ebay.png"
delay 1
keystroke return
end tell
This particular line do JavaScript "$('#lion_upload_btn').click()" in document 1 doesn't work well. It does opens Finder window and picks up a file, but within the web page no file is attached. I think this might be due some custom handler used within jQuery code on that web.
As this page requires login I'm providing a gist link to the source. In a file functions.js SimpleUploader library is used. I can't find the trigger anywhere, not even sure how to debug it. I think there should be some kind of a handler which takes control of click() event, does some logic before file is even picked, and does some logic after file is picked (because it shows file list when they are attached). I believe I need to call that particular handler in order to have correct file attachment.