Şu anda bakım nedeniyle sitemiz kısıtlı işlevsellik sunmaktadır. Mevcut makaleler sorununuzu çözmediyse ve bize soru sormak isterseniz Twitter’da @FirefoxSupport hesabından ve Reddit’teki /r/firefox subreddit'inden destek gönüllülerimize ulaşabilirsiniz.

Mozilla Destek’te Ara

Destek dolandırıcılığından kaçının. Mozilla sizden asla bir telefon numarasını aramanızı, mesaj göndermenizi veya kişisel bilgilerinizi paylaşmanızı istemez. Şüpheli durumları “Kötüye kullanım bildir” seçeneğini kullanarak bildirebilirsiniz.

Daha Fazlasını Öğren

Get user agent string from console

  • 3 yanıt
  • 1 kişi bu sorunu yaşıyor
  • 1 gösterim
  • Son yanıtı yazan: cor-el

more options

I open the terminal (I'm using FreeBSD) and I run: `firefox --help` and I get a lot of command line options. However there seems to be no way to simply get the user agent string. This is kind of annoying because I might want to plug the current version of my Firefox browser in some automated scripts. At the moment I need to open Firefox, then go to the console and type in: `window.navigator.userAgent` copy the string manually and paste it wherever I want to use it. It would be really nice if there could be an extra option to the `firefox` command, like: `firefox --user-agent` that prints this information in the console. Maybe there's a way, if it is it must be really hidden because I couldn't find relevant information on how to do it.

Kind regards, Lucas.

I open the terminal (I'm using FreeBSD) and I run: `firefox --help` and I get a lot of command line options. However there seems to be no way to simply get the user agent string. This is kind of annoying because I might want to plug the current version of my Firefox browser in some automated scripts. At the moment I need to open Firefox, then go to the console and type in: `window.navigator.userAgent` copy the string manually and paste it wherever I want to use it. It would be really nice if there could be an extra option to the `firefox` command, like: `firefox --user-agent` that prints this information in the console. Maybe there's a way, if it is it must be really hidden because I couldn't find relevant information on how to do it. Kind regards, Lucas.

Seçilen çözüm

Yes, the bookmarklet is meant to be used in a running Firefox application.

The user agent can be different for each profile and extensions or the user can override the user agent, so it is not possible to get the user agent from outside Firefox.

If you know the Firefox version then you can construct the agent to replacing the rv:xx.0 and Firefox/xx.0 in the default user agent for this platform and display manager (X11 or Wayland).

For the user agent you used to post this question:

Bu yanıtı konu içinde okuyun 👍 0

Tüm Yanıtlar (3)

more options

You can use a JavaScript bookmarklet:

  • javascript:void(prompt('navigator.userAgent',navigator.userAgent))
more options

Hi cor-el. Thanks for your reply. I'm not fully understanding what you're suggesting. If this involves *opening* the browser then this is definitely something I don't want. The idea is not to open the browser. For example if you open a console in a Linux or BSD box and run: `firefox --version` you will get a string like: "Mozilla Firefox 89.0.2". I'm looking for a similar solution but for the user-agent (hence the suggestion of doing something like: `firefox --user-agent` in the original post). I've attached an image that displays what I'm after.

Kind regards, Lucas.

liendolucas84 tarafından tarihinde düzenlendi

more options

Seçilen çözüm

Yes, the bookmarklet is meant to be used in a running Firefox application.

The user agent can be different for each profile and extensions or the user can override the user agent, so it is not possible to get the user agent from outside Firefox.

If you know the Firefox version then you can construct the agent to replacing the rv:xx.0 and Firefox/xx.0 in the default user agent for this platform and display manager (X11 or Wayland).

For the user agent you used to post this question: