From 691fb0c8d3b7eb7b3fb27c2f4848ae76193a3679 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Tue, 14 Jun 2022 12:50:25 -0500 Subject: [PATCH] Add custom hydration event for userscripts Currently it's difficult for userscripts to determine when hydration is completed so that it's safe to modify the page. This adds a custom mb-hydration event that scripts can listen for. Based on a suggestion by @ROpdebee in https://github.com/jesus2099/konami-command/issues/596#issuecomment-1154386261 --- root/utility/hydrate.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/root/utility/hydrate.js b/root/utility/hydrate.js index 5b62167fcdc..f0ff55cc933 100644 --- a/root/utility/hydrate.js +++ b/root/utility/hydrate.js @@ -139,6 +139,8 @@ export default function hydrate< , ); }); + // Custom event that userscripts can listen for. + root.dispatchEvent(new Event('mb-hydration', {bubbles: true})); } } });