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?


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?