forked from ScratchAddons/ScratchAddons
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserscript.js
More file actions
33 lines (32 loc) · 1.42 KB
/
Copy pathuserscript.js
File metadata and controls
33 lines (32 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { updateTooltips } from "../editor-compact/force-tooltip-update.js";
export default async ({ addon }) => {
while (true) {
const soundEditorRobot = await addon.tab.waitForElement('[class*="sound-editor_row-reverse_"] > :nth-child(10)', {
markAsSeen: true,
});
const echoButton = document.createElement("div");
echoButton.className = addon.tab.scratchClass("icon-button_container", "sound-editor_effect-button");
addon.tab.displayNoneWhileDisabled(echoButton);
echoButton.setAttribute("role", "button");
echoButton.addEventListener("click", () => {
const soundEditorContainer = soundEditorRobot.closest('[class*="sound-editor_editor-container_"]');
soundEditorContainer[
addon.tab.traps.getInternalKey(soundEditorContainer)
].return.return.return.stateNode.handleEffect("echo");
});
const echoIcon = Object.assign(document.createElement("img"), {
src: addon.self.dir + "/echo.svg",
draggable: false,
});
const echoTitleWrapper = Object.assign(document.createElement("div"), {
className: addon.tab.scratchClass("icon-button_title"),
});
const echoTitle = Object.assign(document.createElement("span"), {
textContent: addon.tab.scratchMessage("gui.soundEditor.echo"),
});
echoTitleWrapper.append(echoTitle);
echoButton.append(echoIcon, echoTitleWrapper);
soundEditorRobot.after(echoButton);
updateTooltips();
}
};