You can detect any debugger attached to any browser running V8 with:
let cdp = false;
const orig = Error.prepareStackTrace;
Error.prepareStackTrace = function () {
cdp = true;
return orig;
};
console.log(new Error(''));
// cdp === true → a debugger/automation client has the Runtime domain enabled