Skip to content

Instantly share code, notes, and snippets.

@DanGe42
Last active December 10, 2015 01:19
Show Gist options
  • Save DanGe42/4357372 to your computer and use it in GitHub Desktop.
Save DanGe42/4357372 to your computer and use it in GitHub Desktop.
A naive way of doing something
var toArray = function(orig) {
var arr = [];
for (var i = 0; i < orig.length; i++) {
arr.push(orig[i]);
}
return arr;
}
var find_child_by_class = function(root, klass) {
var queue = toArray(root.children);
var head = null;
while (queue.length > 0) {
head = queue.shift();
if (head.className === klass) {
return head;
} else {
queue = queue.concat(toArray(head.children));
}
}
return null;
}
setInterval(function() {
// Nah, you can easily figure out what goes here
}, 15000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment