Skip to content

Commit e1b6f56

Browse files
authored
Update userscript.js
1 parent c1b911d commit e1b6f56

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/addons/addons/editor-animations/userscript.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ export default async function({ addon }) {
231231
return;
232232
}
233233

234-
element = document.querySelector(`div[class="ReactModalPortal"] div[class*="ReactModal__Overlay"]`)?.firstChild;
234+
element = elementName === "addonModal" ? document.querySelector(`div[class^="modal_modal-overlay"] div[class*="modal_modal-content"]`);
235+
: document.querySelector(`div[class="ReactModalPortal"] div[class*="ReactModal__Overlay"]`)?.firstChild;
235236
if (!element) return;
236237
if (type === "library") {
237238
animTime = 500;
@@ -255,7 +256,8 @@ export default async function({ addon }) {
255256
// Monkey Patch
256257
const ogRemoveChild = document.body.constructor.prototype.removeChild;
257258
document.body.constructor.prototype.removeChild = function(child) {
258-
const element = document.querySelector(`div[class="ReactModalPortal"]`);
259+
const element = elementName === "addonModal" ? document.querySelector(`div[class^="modal_modal-overlay"]`);
260+
: document.querySelector(`div[class="ReactModalPortal"]`);
259261
if (!element) return ogRemoveChild.call(this, child);
260262

261263
let animTime = 200;
@@ -430,9 +432,9 @@ export default async function({ addon }) {
430432
}
431433

432434
/* addon modal API */
433-
addon.traps.vm.on("ADDON_WORKER_MODAL", () => {
434-
handleOpenAnimation("modal");
435-
attachCloseHijack("modal");
435+
window.vm.on("ADDON_WORKER_MODAL", () => {
436+
handleOpenAnimation("addonModal");
437+
attachCloseHijack("addonModal");
436438
});
437439
});
438440
}
@@ -461,7 +463,7 @@ export default async function({ addon }) {
461463
function startListenerWorker() {
462464
const checkInEditor = () => !ReduxStore.getState().scratchGui.mode.isPlayerOnly;
463465

464-
addon.traps.vm.on("workspaceUpdate", () => {
466+
window.vm.on("workspaceUpdate", () => {
465467
queueMicrotask(() => compileClasses());
466468
});
467469

0 commit comments

Comments
 (0)