Skip to content

Commit 09aa23d

Browse files
committed
Elements fix
1 parent 9640447 commit 09aa23d

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

features/video-recorder/popup.html

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,25 @@
1313
</div>
1414
</div>
1515
<style>
16-
video {
16+
.STE-ReactModalPortal .STE-recorded-video {
1717
width: 100%;
1818
height: 100%;
1919
border: 10px solid #ccc;
2020
border-radius: 10px;
2121
}
22-
.STE-hide-button {
22+
23+
.STE-ReactModalPortal .STE-hide-button {
2324
display: none;
2425
}
25-
.STE-left-text {
26+
27+
.STE-ReactModalPortal .STE-left-text {
2628
text-align: left;
2729
}
28-
.stopButton, .startButton, .downloadButton, .video-format-select {
30+
31+
.STE-ReactModalPortal .stopButton,
32+
.STE-ReactModalPortal .startButton,
33+
.STE-ReactModalPortal .downloadButton,
34+
.STE-ReactModalPortal .video-format-select {
2935
width: 100%;
3036
}
3137
</style>
@@ -43,11 +49,11 @@
4349
</select>
4450
<br><br>
4551
Preview: <br>
46-
<video></video>
52+
<video class="STE-recorded-video"></video>
4753
<button class="prompt_ok-button_3QFdD downloadButton"><span>Download Video</span></button>
4854
</div>
4955
</div>
5056
</div>
5157
</div>
5258
</div>
53-
</div>
59+
</div>

features/video-recorder/video-recorder.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
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";
5-
62
await new Promise(async (resolve, reject) => {
73
(async () => {
8-
const rem = await ScratchTools.waitForElement(".preview .inner .flex-row.action-buttons")
4+
const rem = await ScratchTools.waitForElement(".preview .inner .flex-row.action-buttons")
95
resolve(rem);
106
})();
117
(async () => {
128
const rem = await ScratchTools.waitForElement(".menu-bar_account-info-group_MeJZP")
139
resolve(rem);
1410
})();
1511
})
12+
13+
let openPopup = document.createElement("button");
1614

1715
ScratchTools.waitForElements(".preview .inner .flex-row.action-buttons", async function (row) {
1816
if (row.querySelector(".ste-video-recorder-open")) return;
17+
openPopup = document.createElement("button");
18+
openPopup.className = "button action-button ste-video-recorder-open";
19+
openPopup.textContent = "Record Video";
1920
row.insertAdjacentElement("afterbegin", openPopup);
21+
openPopup.addEventListener('click', () => {
22+
document.body.append(popup)
23+
})
2024
})
2125
ScratchTools.waitForElements(".menu-bar_account-info-group_MeJZP", async function (row) {
2226
if (row.querySelector(".ste-video-recorder-open")) return;
27+
openPopup = document.createElement("div");
28+
openPopup.className = "menu-bar_menu-bar-item_oLDa- menu-bar_hoverable_c6WFB";
29+
openPopup.textContent = "Record Video";
2330
row.insertAdjacentElement("afterbegin", openPopup);
31+
openPopup.addEventListener('click', () => {
32+
document.body.append(popup)
33+
})
2434
})
25-
35+
2636
let popup = document.createElement("div");
2737
popup.insertAdjacentHTML("afterbegin", await (await fetch(feature.self.getResource("popup-html"))).text())
2838
popup = popup.querySelector("div.ReactModalPortal")
@@ -31,17 +41,10 @@ export default async function ({ feature, console }) {
3141
let startButton = popup.querySelector(".startButton");
3242
let closeButton = popup.querySelector(".close-button_close-button_lOp2G");
3343
let downloadButton = popup.querySelector(".downloadButton");
34-
let lastDownloadFunction = ()=>{}
44+
let lastDownloadFunction = () => { }
3545
let mimeType = popup.querySelector("select");
3646

3747

38-
// console.log([stopButton, startButton])
39-
40-
openPopup.addEventListener('click', () => {
41-
document.body.append(popup)
42-
})
43-
44-
// console.log(closeButton)
4548
closeButton.addEventListener('click', () => {
4649
document.querySelector(".STE-ReactModalPortal").remove()
4750
})
@@ -82,7 +85,7 @@ export default async function ({ feature, console }) {
8285
preview.controls = true;
8386
preview.download = `${projectTitle.value}.${mimeType.value}`
8487
downloadButton.removeEventListener("click", lastDownloadFunction)
85-
lastDownloadFunction = async () => {
88+
lastDownloadFunction = async () => {
8689
const url = URL.createObjectURL(blob)
8790
const a = document.createElement('a')
8891
a.href = url

0 commit comments

Comments
 (0)