Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
77 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const mutationWatcher = new MutationObserver(list => { | ||
console.log("[EVENT] On DOM mutate", list.length); | ||
list.forEach(entry => { | ||
if (entry.type == "childList") { | ||
console.log( | ||
"A child node has been added(%s) or removed(%s) [%d].", | ||
entry.addedNodes, | ||
entry.removedNodes, | ||
window.performance.now() | ||
); | ||
// console.log((entry.target as any).innerText); | ||
// console.log(entry.addedNodes[0]); | ||
// console.log(entry.target.textContent); | ||
} else if (entry.type == "attributes") { | ||
console.log("The " + entry.attributeName + " attribute was modified."); | ||
} else { | ||
console.log(entry.target, entry.type, window.performance.now()); | ||
} | ||
}); | ||
}); | ||
|
||
const performanceWatcher = new PerformanceObserver(list => { | ||
console.log("[EVENT] On Perf entity changed"); | ||
list.getEntries().forEach(entry => { | ||
console.log( | ||
"[%s]: %s %d..%d", | ||
entry.entryType, | ||
entry.name, | ||
entry.startTime, | ||
entry.startTime + entry.duration | ||
); | ||
}); | ||
}); | ||
|
||
mutationWatcher.observe(document.body, { | ||
characterData: true, | ||
attributes: true, | ||
childList: true, | ||
subtree: true | ||
}); | ||
|
||
performanceWatcher.observe({ | ||
entryTypes: ["frame", "navigation", "resource", "paint"] | ||
}); | ||
|
||
window.addEventListener("close", () => { | ||
mutationWatcher.disconnect(); | ||
performanceWatcher.disconnect(); | ||
}); |
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
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
File renamed without changes.
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
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
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