Skip to content

Commit 7712806

Browse files
authored
Better method
1 parent a97a1dc commit 7712806

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

features/bitmap-default/script.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
export default async function ({ feature, console }) {
2-
ScratchTools.waitForElements(".paint-editor_bitmap-button_OEHDO", (bitmapButton) => {
3-
if (feature.self.enabled) {
1+
export default async function ({ feature }) {
2+
ScratchTools.waitForElements("body", () => {
3+
const observer = new MutationObserver(() => {
4+
const bitmapButton = document.querySelector(".paint-editor_bitmap-button_OEHDO");
5+
if (bitmapButton && feature.self.enabled) {
46
bitmapButton.click();
57
}
68
});
7-
}
8-
9+
observer.observe(document.body, { childList: true, subtree: true });
10+
});
11+
}

0 commit comments

Comments
 (0)