Created
May 8, 2013 05:49
-
-
Save nebuta/5538501 to your computer and use it in GitHub Desktop.
MutationObserver example
This file contains 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
function findTitle(rec){ | |
var res = undefined; | |
$.each(rec,function(){ | |
if(this.localName == 'title'){ | |
res = this.innerText; | |
} | |
}); | |
return res; | |
} | |
var obs = new MutationObserver(function(mutations) { | |
$.each(mutations,function(idx){ | |
var t = findTitle(this.addedNodes); | |
if(t){ | |
console.log(t); | |
} | |
}); | |
}).observe(document, { | |
attributes: true, | |
childList: true, | |
subtree: true, | |
attributeFilter: ["head"] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment