Skip to content

Instantly share code, notes, and snippets.

@gabriel-dehan
Last active October 23, 2017 13:06
Show Gist options
  • Save gabriel-dehan/fd9cd0db1c35255637caf81114b4348e to your computer and use it in GitHub Desktop.
Save gabriel-dehan/fd9cd0db1c35255637caf81114b4348e to your computer and use it in GitHub Desktop.
cryptohelp
var target = $(".log")[0];
var log = {};
// level 3 error
// level 2 warn
// level 1 info
// level 0 debug
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length > 0) {
var node = $(mutation.addedNodes[0]),
classes = node.attr('class');
if (classes.match(/level/)) {
var level = classes;
var time = node.find(".time").text();
var text = node.find(".message").text();
log[time] = log[time] || []
log[time].push({
level: level,
message: message
});
}
}
});
});
// configuration of the observer:
var config = { attributes: true, childList: true, characterData: true };
// pass in the target node, as well as the observer options
observer.observe(target, config);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment