iamtheyammer

mutationobserver

Apr 24th, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. var color = document.documentElement.style.backgroundColor;
  2. document.documentElement.style.backgroundColor = "black";
  3. var observer = new MutationObserver(function(mutations) {
  4. mutations.forEach(function(mutation) {
  5. if (mutation.target.nodeName == "BODY") {
  6. observer.disconnect();
  7. document.documentElement.style.backgroundColor = color || "";
  8. }
  9. });
  10. });
  11. observer.observe(document, { childList: true, subtree: true });
Advertisement
Add Comment
Please, Sign In to add comment