Last active
November 17, 2015 16:16
-
-
Save raykendo/6228bc613c6e60037d17 to your computer and use it in GitHub Desktop.
George Washington - A user testing test
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
/** | |
* This script is a test to see whether the people who are supposed to be user testing your site are actually doing | |
* anything. It injects a piece of red text with content of George Washington somewhere in the document. It's designed | |
* to look for lowest hanging HTML dom nodes in the DOM tree (no children elements) that are visible (offsetParent is not null). | |
*/ | |
(function () { | |
var nodes = Array.prototype.filter.call(document.querySelectorAll('div, p, span, blockquote, code, a, td'), function (node) { | |
return !(node.children && node.children.length) && node.offsetParent !== null; | |
}); | |
if (nodes.length) { | |
nodes[Math.floor(Math.random() * nodes.length)].innerHTML += '<span style=\'color:red;font-weight:bold;\'>George Washington</span>'; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment