new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

Electron · API · all subjects

webcontents: user agent

5 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

app.userAgentFallback property

app.userAgentFallback is a string which is the user agent string Electron will use as global fallback when no user agent is set at webContents or session level. Useful for ensuring entire app has same user agent. Should be set to custom value early in app initialization.

setUserAgent method with acceptLanguages parameter

The setUserAgent method overrides the userAgent and optionally acceptLanguages for a session. Parameters are: userAgent (string), acceptLanguages (string, optional). The acceptLanguages must be a comma-separated ordered list of language codes, for example 'en-US,fr,de,ko,zh-CN,ja'. This does not affect existing WebContents; each WebContents can use webContents.setUserAgent to override the session-wide user agent.

webview user agent methods

setUserAgent(userAgent) overrides the user agent for guest page after page has loaded. getUserAgent() returns the user agent string for the guest page.

contents.setUserAgent() method

The contents.setUserAgent(userAgent) method sets userAgent (string) and overrides the user agent for this web page.

contents.getUserAgent() method

The contents.getUserAgent() method returns string - the user agent for this web page.

Give your agent this brain