|
1 | 1 | export default async function ({ feature, console }) { |
| 2 | + let openPopup = document.createElement("button"); |
| 3 | + openPopup.className = "button action-button ste-video-recorder-open"; |
| 4 | + openPopup.textContent = "Record Video"; |
2 | 5 |
|
3 | | - const row = await new Promise(async (resolve, reject) => { |
| 6 | + await new Promise(async (resolve, reject) => { |
4 | 7 | (async () => { |
5 | | - const rem = await ScratchTools.waitForElement(".preview .inner .flex-row.action-buttons") |
| 8 | + const rem = await ScratchTools.waitForElement(".preview .inner .flex-row.action-buttons") |
6 | 9 | resolve(rem); |
7 | 10 | })(); |
8 | 11 | (async () => { |
9 | 12 | const rem = await ScratchTools.waitForElement(".menu-bar_account-info-group_MeJZP") |
10 | 13 | resolve(rem); |
11 | 14 | })(); |
12 | 15 | }) |
13 | | - |
14 | | - let openPopup = document.createElement("button"); |
15 | | - openPopup.className = "button action-button ste-video-recorder-open"; |
16 | | - openPopup.textContent = "Record Video"; |
17 | | - row.insertAdjacentElement("afterbegin", openPopup); |
18 | | - |
| 16 | + |
| 17 | + ScratchTools.waitForElements(".preview .inner .flex-row.action-buttons", async function (row) { |
| 18 | + if (row.querySelector(".ste-video-recorder-open")) return; |
| 19 | + row.insertAdjacentElement("afterbegin", openPopup); |
| 20 | + }) |
| 21 | + ScratchTools.waitForElements(".menu-bar_account-info-group_MeJZP", async function (row) { |
| 22 | + if (row.querySelector(".ste-video-recorder-open")) return; |
| 23 | + row.insertAdjacentElement("afterbegin", openPopup); |
| 24 | + }) |
| 25 | + |
19 | 26 | let popup = document.createElement("div"); |
20 | 27 | popup.insertAdjacentHTML("afterbegin", await (await fetch(feature.self.getResource("popup-html"))).text()) |
21 | 28 | popup = popup.querySelector("div.ReactModalPortal") |
|
0 commit comments