Last active
May 31, 2016 08:18
-
-
Save fblundun/4937e1b0a94cd295cb6a to your computer and use it in GitHub Desktop.
Detect Snowplow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = require('webpage').create(); | |
var system = require('system'); | |
if (system.args.length === 1) { | |
console.log('Usage: you must provide some URL to check'); | |
phantom.exit(); | |
} | |
page.open(system.args[1], function(status) { | |
var usesSnowplow; | |
var information; | |
if(status === "success") { | |
var answer = page.evaluate(function(){ | |
return window.GlobalSnowplowNamespace !== undefined || window._snaq !== undefined; | |
}); | |
usesSnowplow = answer; | |
information = usesSnowplow ? "YES" : "NO"; | |
} else { | |
information = "UNKNOWN"; | |
} | |
console.log(system.args[1] + " : " + information); | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First install phantomJS.
Then run
Output is YES if the site does have Snowplow, NO if it doesn't, and UNKNOWN if the connection failed.