javascript - How to catch google chrome audit lighthouse - Stack Overflow

How can I catch in Javascript a user running an Audit from Lighthouse in my website?I'd like to se

How can I catch in Javascript a user running an Audit from Lighthouse in my website?

I'd like to see if there is a possibility, out of curiosity.

Edit:

Based on @DBS answer, I'd like to see that If I can catch it during the process

    <script>
        if (navigator.userAgent.indexOf("Chrome-Lighthouse") > -1) {
            document.body.innerHTML = "Lighthouse!";
        } else {
            document.body.innerHTML = "No lighthouse :("
        }
    </script>

How can I catch in Javascript a user running an Audit from Lighthouse in my website?

I'd like to see if there is a possibility, out of curiosity.

Edit:

Based on @DBS answer, I'd like to see that If I can catch it during the process

    <script>
        if (navigator.userAgent.indexOf("Chrome-Lighthouse") > -1) {
            document.body.innerHTML = "Lighthouse!";
        } else {
            document.body.innerHTML = "No lighthouse :("
        }
    </script>

Share Improve this question edited Aug 8, 2019 at 10:34 6be709c0 asked Aug 8, 2019 at 9:56 6be709c06be709c0 8,4814 gold badges39 silver badges53 bronze badges 1
  • As far as i know there isn't any possibility. – cloned Commented Aug 8, 2019 at 10:06
Add a ment  | 

2 Answers 2

Reset to default 4

If by "catch", you simply mean detect it. The Lighthouse process includes a custom user agent.

Searching the user agent for the string Chrome-Lighthouse

e.g.

if (navigator.userAgent.indexOf("Chrome-Lighthouse") > -1) {
  console.log("Lighthouse!");
} else {
  console.log("No lighthouse :(")
}

I don't believe it's possible to "catch" in the debugging sense of interacting with the process.

You might be able to catch it from the User agent.
Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3694.0 Mobile Safari/537.36 Chrome-Lighthouse

From Source Code

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745365898a4624577.html

相关推荐

  • javascript - How to catch google chrome audit lighthouse - Stack Overflow

    How can I catch in Javascript a user running an Audit from Lighthouse in my website?I'd like to se

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信