Override User Agent

Q: Is there a way to force PSPDFKit to use the Web version and not the Electron version when loading?

A: It is possible to inject some code that monkey-patches navigator.userAgent to not include Electron/ in the string.

Here’s an example that uses the current Chrome User Agent.

const chromeUserAgent =
  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36";
Object.defineProperty(navigator, "userAgent", { get: () => chromeUserAgent });

This has been tested with PSPDFKit for Web 2019.4.1