tell application "System Events" to get value of UI element 1 of combo box 1 of toolbar "Navigation" of first group of front window of application process "Firefox"
I am using the above in an AppleScript to get the URL from the Firefox browser, what would the equivalent be using JXA. I am using JXA rather than an AppleScript because applescripts hate when you don't have a specific browser installed but still use it in the script.
Here I tested the apple-script you mentioned from the GitHub site that you would like to translate into JXA.
It contains 2 important bugs: 1) When the script is run, the front application is one, which executes the script and not the browser. This has been erroneously ignored. 2) If you do not have the Google Chrome application installed, then the script will not even compile.
The following Apple-script fixes these 2 critical bugs. I am not a JXA expert, so I leave my script as is.