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
2 Answers
Reset to default 4If 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
评论列表(0条)