Skip to content

Instantly share code, notes, and snippets.

@m1k1o
Created May 8, 2019 21:25
Show Gist options
  • Save m1k1o/843183767f2ab2aebab52959e2eaec1c to your computer and use it in GitHub Desktop.
Save m1k1o/843183767f2ab2aebab52959e2eaec1c to your computer and use it in GitHub Desktop.
Check if client is not Phantom.Js et. al.
function isNotPhantomJs() {
try {
null[0]();
return false
} catch (e) {
return !(typeof e.stack === 'undefined' || e.stack.toString().indexOf('phantomjs') != -1 || ('toString' in Math.sin && Math.sin.toString().indexOf('[native code') != -1 && document.getElementById.toString().indexOf('[native code') == -1) || window.callPhantom || /Phantom/.test(navigator.userAgent) || window.__phantomas || window.domAutomation || window.webdriver || document.documentElement.getAttribute('webdriver'))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment