I want a particular JavaScript function to behave differently depending on if it's called within JavaScript code referenced from an HTML page or called from within a console. Is this possible? Something like the following:
function mySpecialFunc() {
if (inConsole())
console.log("You called me from the console!");
else
console.log("You called me from an HTML page or a JavaScript file linked from an HTML page, I think.");
}
Does something equivalent to the inConsole()
function above exist?
Does this exist for at least just Chrome specifically, or Firefox specifically?