Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox Extensions get current User-Agent

I know that we are able to change useragent string by setting key general.browser.useragent.override

but how can I get current useragent string when it's not available through nsIPrefService ?

like image 924
Marek Sebera Avatar asked Apr 16 '26 13:04

Marek Sebera


1 Answers

The userAgent property on nsIHttpProtocolHandler should give this to you. http://hg.mozilla.org/mozilla-central/file/ddaf5686c70c/services/sync/modules/service.js#l378 shows a typical usage.

That's assuming you're in a JS component. If you're running in a Window object, just use navigator.userAgent.

like image 63
Boris Zbarsky Avatar answered Apr 20 '26 23:04

Boris Zbarsky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!