Hi.
I have done things like this in the past with Applescript. Firefox has poor support however. So perhaps use Chrome.
Now, like me, if your Applescript knowledge isn't great — go and download a free trial of UIBrowser
Next take a look at how to use it from Dan Thomas
You can probably build something using a combination of applescript and KBM.
Take a look at the first step: Click Chrome extension button
Have fun.