Created
March 4, 2022 17:44
-
-
Save saitergun/15ec00776ec68fc51183f4066626a643 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// select the target node | |
var target = document.querySelector('title') | |
// create an observer instance | |
var observer = new MutationObserver(function(mutations) { | |
// We need only first event and only new value of the title | |
console.log('title changes', document.title) | |
}) | |
// configuration of the observer: | |
var config = { subtree: true, characterData: true, childList: true } | |
// pass in the target node, as well as the observer options | |
observer.observe(target, config) | |
// credit https://stackoverflow.com/a/29540461/5765524 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment