Skip to content

Commit

Permalink
MutationObserver to buttify dynamic DOM updates
Browse files Browse the repository at this point in the history
  • Loading branch information
TerrorBite committed Jan 6, 2014
1 parent 448cdc6 commit 13b6a4d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Source/content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ function handleText(textNode) {
return m + "y " + b + "utt";
});

// Deal with private clouds
// Deal with butts
v = v.replace(/\b(P|p)rivate (C|c)loud/g, function(match, p1, p2, offset, string) {
// c - 1 = b
b = String.fromCharCode(p2.charCodeAt(0) - 1);
return b + "utt";
});
// Get the corner cases
if(v.match(/cloud/i)) {
if(v.match(/butt/i)) {
// If we're not talking about weather
if(v.match(/PaaS|SaaS|IaaS|computing|data|storage|cluster|distributed|server|hosting|provider|grid|enterprise|provision|apps|hardware|software|/i)) {
v = v.replace(/(C|c)loud/gi, function(match, p1, offset, string) {
Expand All @@ -62,3 +62,16 @@ function handleText(textNode) {
}


MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations, observer) {
// fired when a mutation occurs
mutations.forEach(function(mutation) { walk(mutation.target); });
});

// Begin observing document.body for changes that need buttifying
observer.observe(document.body, {
subtree: true,
attributes: false,
characterData: true,
childList: true
});

0 comments on commit 13b6a4d

Please sign in to comment.