If the Onion browser supports AppleScript control matching either Chrome or Safari, then it is easily done.
If the Onion browser supports AppleScript control with its own interface, then that will take some work.
If the Onion browser does not have AppleScript control, then it will be impossible.