Article 596X8 Get Firefox User-Agent programmatically?

Get Firefox User-Agent programmatically?

by
ondoho
from LinuxQuestions.org on (#596X8)
That's what I'm trying to do.
It seems impossible.
I can see it on about:support, but there's no way to get it out with a script.

I wrote a ridiculously complicated shell script that makes netcat listen on a port, then opens FF headlessly to request something from that port, at which point netcat spits out the request metadata.
This works well enough but I just cannot believe that that's the best way to do it. :(

Another way is to locate FF's libxul.so and get the elements of the UA with strings - the complete UA is not in there, it's comprised of revision and whatnot:
Code:$> strings libxul.so |grep -E 'Mozilla/5\.0|78\.0|20100101'
rv:78.0
Firefox/78.0
20100101
Mozilla/5.0 (%s; rv:%d.0) Gecko/%s Firefox/%d.0Not good.

I don't want to use one of the many what's-my-user-agent sites, either.

I could imagine a quick PHP script so I could request it from my server, but that still involves opening the browser and making the request. Worse, not better.

Is there a better way?
Locally?latest?d=yIl2AUoC8zA latest?i=2ujffLNIUPQ:evNoIlGf5Fc:F7zBnMy latest?i=2ujffLNIUPQ:evNoIlGf5Fc:V_sGLiP latest?d=qj6IDK7rITs latest?i=2ujffLNIUPQ:evNoIlGf5Fc:gIN9vFw2ujffLNIUPQ
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments