11export 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