1 // Detect if a web page sniffs the user agent or not.
4 var page = require('webpage').create(),
5 system = require('system'),
9 page.onInitialized = function () {
10 page.evaluate(function () {
13 var userAgent = window.navigator.userAgent,
14 platform = window.navigator.platform;
17 appCodeName: 'Mozilla',
23 window.navigator.__defineGetter__('userAgent', function () {
24 window.navigator.sniffed = true;
28 window.navigator.__defineGetter__('platform', function () {
29 window.navigator.sniffed = true;
36 if (system.args.length === 1) {
37 console.log('Usage: detectsniff.js <some URL>');
40 address = system.args[1];
41 console.log('Checking ' + address + '...');
42 page.open(address, function (status) {
43 if (status !== 'success') {
44 console.log('FAIL to load the address');
47 window.setTimeout(function () {
48 sniffed = page.evaluate(function () {
49 return navigator.sniffed;
52 console.log('The page tried to sniff the user agent.');
54 console.log('The page did not try to sniff the user agent.');