Last active
August 29, 2015 14:26
-
-
Save arantius/77d8a42fc3bd3a30972b to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name Title Mutation Logger | |
// @version 1 | |
// @include * | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
console.log('user script mutation observer setup ...'); | |
console.log(document.documentElement.innerHTML); | |
MutationObserver = window.MutationObserver; | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
var addedNodes = mutation.addedNodes; | |
for (var i = 0; i < addedNodes.length; i++) { | |
if (addedNodes[i].nodeName == 'TITLE') { | |
console.log("Yes, script is active! Hurray!"); | |
} | |
} | |
}); | |
}); | |
observer.observe(document, {childList: true, subtree: true, attributes: true}); |
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
<html> | |
<head> | |
<meta charset='utf-8'> | |
<title>Mutation Event Test Page 1</title> | |
<script>console.log('content of Mutation Event Test Page 1');</script> | |
</head> | |
<body> | |
<p>Mutation Event Test Page 1</p> | |
</body> |
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
<html> | |
<head> | |
<meta charset='utf-8'> | |
<script>console.log('content of Mutation Event Test Page 2');</script> | |
<title>Mutation Event Test Page 2</title> | |
</head> | |
<body> | |
<p>Mutation Event Test Page 2</p> | |
</body> |
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
<html> | |
<head> | |
<meta charset='utf-8'> | |
<title>Mutation Event Test Page 2</title> | |
</head> | |
<body> | |
<p>Mutation Event Test Page 2</p> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment