Skip to content

Instantly share code, notes, and snippets.

@raykendo
Last active November 17, 2015 16:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raykendo/6228bc613c6e60037d17 to your computer and use it in GitHub Desktop.
Save raykendo/6228bc613c6e60037d17 to your computer and use it in GitHub Desktop.
George Washington - A user testing test
/**
* 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