Detect automation browsers on extension install

Viewed 58

I want to detect if my extension has been installed from a normal browser or with an automation tool. in Manifest v2 it was possible because we could access the window object from the background and we use navigator.webdriver property but now in Manifest v3 we can't anymore because of Service Worker.

Is there any alternative solution?

Update:

Here I got the solution in other way. Like we can detect if extension crx file is loaded locally from below method-

const self = await browserType.management.getSelf(); 

if(self.installType === "normal"){
 console.log("extension installed locally"); 
}
else if(self.installType === "development"){ 
console.log("extension installed from store"); } 
1 Answers

Method one

let id = chrome.runtime.id  

if (id)
  console.log("id found, not headless")

Method Two

let checkIfheadless = navigator.language || navigator.userLanguage || navigator.browserLanguage || navigator.systemLanguage if (checkIfheadless)   console.log("not headless")

Method Three

  const phantomJsCheck = function () {
    if (!Function.prototype.bind) {
      console.log("PhantomJS environment detected. #1");
      return;
    }
    if (Function.prototype.bind.toString().replace(/bind/g, 'Error') != Error.toString()) {
      console.log("PhantomJS environment detected. #2");
      return;
    }
    if (Function.prototype.toString.toString().replace(/toString/g, 'Error') != Error.toString()) {
      console.log("PhantomJS environment detected. #3");
      return;
    }
    console.log("PhantomJS environment not detected.");
  }

Related