Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Commit

Permalink
Handle async loading of new nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
murphyne committed Mar 25, 2021
1 parent 453a8b8 commit c416681
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion no-anonymous.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Eliminate $$anonymous$$
// @namespace http://tampermonkey.net/
// @version 0.3.1
// @version 0.3.2
// @description Replace $$anonymous$$ on Unity Answers!
// @author murphyne
// @match https://answers.unity.com/*
Expand Down Expand Up @@ -66,6 +66,18 @@
var nodes = traverseNodeTree(document.body).flat(Infinity);
processNodes(nodes);

const documentObserver = new MutationObserver(function documentCallback (mutations) {
for (let i = 0; i < mutations.length; i++) {
const mutation = mutations[i];
for (let j = 0; j < mutation.addedNodes.length; j++) {
const root = mutation.addedNodes[j];
var nodes = traverseNodeTree(root).flat(Infinity);
processNodes(nodes);
}
}
});
documentObserver.observe(document, {subtree: true, childList: true});

function processNodes (nodes) {
for (let node of nodes) {
if (node.nodeName === "A") {
Expand Down

0 comments on commit c416681

Please sign in to comment.