Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable the emulatedUserAgent? #73

Open
ArielDing opened this issue Nov 24, 2021 · 4 comments
Open

How to disable the emulatedUserAgent? #73

ArielDing opened this issue Nov 24, 2021 · 4 comments

Comments

@ArielDing
Copy link

I use lighthouse-batch -s <url1,url2> --params "--chrome-flags="--screenEmulation.disable --screenEmulation.mobile=false --screenEmulation.width=1350 --screenEmulation.height=940 --no-emulatedUserAgent"" --html ./report.html
but the device has always been emulation device.

image

@calumy
Copy link

calumy commented Dec 2, 2021

One workaround would be to create a configuration file for use with lighthouse. For example, a file called config.js could be created with (update for your requirements):

const config = {
  extends: "lighthouse:default",
  settings: {
    formFactor: "desktop",
    throttling: {
      rttMs: 40,
      throughputKbps: 10 * 1024,
      cpuSlowdownMultiplier: 1,
      requestLatencyMs: 0,
      downloadThroughputKbps: 0,
      uploadThroughputKbps: 0,
    },
    screenEmulation: {
      mobile: false,
      width: 1907,
      height: 1094,
      deviceScaleFactor: 1,
      disabled: false,
    },
    emulatedUserAgent:
      "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4695.0 Safari/537.36 Chrome-Lighthouse",
  },
};

module.exports = config;

Then this would be called like this:
lighthouse-batch -s <url1,url2> --params "--config-path=config.js" --html

More details on lighthouse configuration can be found here: https://github.com/GoogleChrome/lighthouse/blob/master/docs/configuration.md

@ArielDing
Copy link
Author

Thanks for your suggestion. I was sucessed with config file. But I have another question, how to run sites.txt for many tinmes with lighthouse-batch? for example, how to run "url" 5 times?

@calumy
Copy link

calumy commented Jan 20, 2022

You can create a file containing a list of URLs separated on new lines and then run a command like lighthouse-batch -f ./test_sites.txt to run a series of urls. To see more you can look at the all options section of the read me.

@ArielDing
Copy link
Author

You can create a file containing a list of URLs separated on new lines and then run a command like lighthouse-batch -f ./test_sites.txt to run a series of urls. To see more you can look at the all options section of the read me.

emmm...My sites.txt cotain 60 urls, but i need to run them 5 times to get the
average score. Is there a way to solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants