@@ -21,6 +21,14 @@ function IsOnQuest() {
2121 return location . host . startsWith ( "127.0.0.1" ) || location . host . startsWith ( "localhost" )
2222}
2323
24+ function GetPort ( ) {
25+ return location . port
26+ }
27+
28+ document . getElementById ( "cancellogin2" ) . onclick = ( ) => {
29+ CloseGetPasswordPopup ( )
30+ }
31+
2432fetch ( "/api/android/device" ) . then ( res => res . json ( ) . then ( res => {
2533 if ( res . sdkVersion <= 29 ) {
2634 // Android 10 and below don't need new storage perms
@@ -174,7 +182,7 @@ function UpdateVersion(version) {
174182
175183var isGamePatched = false
176184const patchingOptions = document . getElementById ( "patchingOptions" )
177-
185+ var patchingStatus = { }
178186function UpdatePatchingStatus ( ) {
179187 if ( patchInProgress ) {
180188 return ;
@@ -183,6 +191,7 @@ function UpdatePatchingStatus() {
183191 fetch ( "/api/patching/getmodstatus" ) . then ( res => {
184192 res . json ( ) . then ( res => {
185193 UpdateVersion ( res . version )
194+ patchingStatus = res
186195 isGamePatched = res . isPatched
187196 if ( res . isPatched ) {
188197 document . getElementById ( "modsButton" ) . style . display = "block"
@@ -448,6 +457,38 @@ UpdateUI()
448457TokenUIUpdate ( )
449458const oculusLink = "https://auth.meta.com/"
450459const params = new URLSearchParams ( window . location . search )
460+
461+ function CheckStartParams ( ) {
462+ var download = params . get ( "download" )
463+ var game = params . get ( "game" )
464+ var version = params . get ( "version" )
465+ var package = params . get ( "package" )
466+ var modnow = params . get ( "modnow" )
467+ if ( download ) {
468+ fetch ( "/api/questappversionswitcher/loggedinstatus" ) . then ( res => {
469+ res . json ( ) . then ( res => {
470+ if ( res . msg == "2" ) {
471+ // Logged in
472+ // Open downgrade tab
473+ OpenTab ( "downgrade" )
474+ // Open OculusDB on correct page
475+ document . getElementById ( "downgradeframe" ) . src = `https://oculusdb.rui2015.me/id/${ game } ?downloadversion=${ version } `
476+ } else {
477+ // Not logged in
478+ OpenGetPasswordPopup ( )
479+ GotoStep ( 13 )
480+ }
481+ } )
482+ } )
483+ }
484+
485+ if ( modnow ) {
486+ ChangeApp ( package )
487+ OpenTab ( "patching" )
488+ PatchGame ( )
489+ }
490+ }
491+
451492var config = { }
452493var selectedBackup = ""
453494
@@ -480,6 +521,7 @@ function UpdateUI(closeLists = false) {
480521 if ( firstConfigFetch ) {
481522 firstConfigFetch = false ;
482523 CheckFolderPermission ( ) ;
524+ CheckStartParams ( )
483525 }
484526 Array . prototype . forEach . call ( document . getElementsByClassName ( "packageName" ) , e => {
485527 if ( config . currentApp ) e . innerHTML = config . currentApp
@@ -561,7 +603,7 @@ function FormatDownload(d) {
561603 </div>
562604 ${ d . isCancelable ? `<input type="button" class="DownloadText" value="Cancel" onclick="StopDownload('${ d . backupName } ')">` : `` }
563605 <div class="DownloadText" style="color: ${ d . textColor } ;">
564- ${ d . text } ${ d . percentageString } ${ d . doneString } / ${ d . totalString } ${ d . speedString } ETA ${ d . eTAString }
606+ <b> ${ d . text } </b> ${ d . percentageString } ${ d . doneString } / ${ d . totalString } ${ d . speedString } ETA ${ d . eTAString }
565607 </div>
566608 </div>`
567609}
@@ -580,7 +622,7 @@ setInterval(() => {
580622 downloads += FormatDownload ( download )
581623 }
582624 gdms += `<div style="display: flex; flex-direction: column; background-color: #1F1F1F; padding: 10px;"><div class="downloadContainer">
583- ${ ! d . done ? ` <input type="button" class="DownloadText" style="width: 0px ; background-color: #333333" value="Cancel" onclick="StopGameDownload('${ d . id } ')">` : `` }
625+ ${ ! d . done ? ( d . canceled || d . error ? `` : ` <input type="button" class="DownloadText" style="width: 200px ; background-color: #333333; font-size: 1.2em; " value="Cancel" onclick="StopGameDownload('${ d . id } ')">`) : `<input type="button" class="DownloadText" style="width: 200px; background-color: #333333; color: #00FF00; font-size: 1.2em;" value="Install Version" onclick="RestoreBackup(' ${ d . backupName } ', ' ${ d . packageName } ')"> ` }
584626 <div class="DownloadText" style="color: ${ d . textColor } ;">
585627 <b>${ d . canceled ? "Cancelled " : "" } ${ d . status } </b><br>${ d . filesDownloaded } / ${ d . filesToDownload } files downloaded
586628 </div>
@@ -682,13 +724,15 @@ setInterval(() => {
682724 } )
683725} , 500 )
684726
727+ if ( localStorage . lastOpened ) OpenTab ( localStorage . lastOpened )
685728function OpenTab ( section ) {
686729 Array . prototype . forEach . call ( document . getElementsByClassName ( "menuItem" ) , e => {
687730 e . className = "menuItem" + ( e . getAttribute ( "section" ) == section ? " selected" : "" )
688731 } )
689732 Array . prototype . forEach . call ( document . getElementsByClassName ( "contentItem" ) , e => {
690733 e . className = "contentItem" + ( e . id == section ? "" : " hidden" )
691734 } )
735+ localStorage . lastOpened = section
692736}
693737
694738
@@ -775,7 +819,7 @@ document.getElementById("uninstall2").onclick = () => {
775819 fetch ( `/api/backupinfo?package=${ config . currentApp } &backupname=${ selectedBackup } ` ) . then ( res => {
776820 res . json ( ) . then ( j => {
777821 if ( ! j . containsApk ) {
778- GotoStep ( "4.1" )
822+ AfterAPKInstall ( )
779823 } else {
780824 fetch ( `/api/android/uninstallpackage?package=${ config . currentApp } ` , { method : "POST" } ) . then ( res => {
781825 if ( res . status == 230 ) GotoStep ( 3 )
@@ -805,29 +849,33 @@ document.getElementById("install").onclick = () => {
805849 } ) . then ( res => {
806850 res . json ( ) . then ( j => {
807851 if ( res . status == 200 ) {
808- fetch ( "/api/gotaccess?package=" + config . currentApp ) . then ( res => {
852+ AfterAPKInstall ( )
853+ }
854+ else TextBoxError ( "step4.1box" , j . msg )
855+ } )
856+ } )
857+ }
858+
859+ function AfterAPKInstall ( ) {
860+ fetch ( "/api/gotaccess?package=" + config . currentApp ) . then ( res => {
861+ res . json ( ) . then ( j => {
862+ if ( j . gotAccess ) {
863+ fetch ( "/api/backupinfo?package=" + config . currentApp + "&backupname=" + selectedBackup ) . then ( res => {
809864 res . json ( ) . then ( j => {
810- if ( j . gotAccess ) {
811- fetch ( "/api/backupinfo?package=" + config . currentApp + "&backupname=" + selectedBackup ) . then ( res => {
812- res . json ( ) . then ( j => {
813- if ( j . isPatchedApk ) {
814- GotoStep ( "4.2" )
815- } else {
816- if ( j . containsAppData || j . containsObbs ) {
817- GotoStep ( 4 )
818- } else {
819- GotoStep ( 5 )
820- }
821- }
822- } )
823- } )
865+ if ( j . isPatchedApk ) {
866+ GotoStep ( "4.2" )
824867 } else {
825- GotoStep ( "4.1" )
868+ if ( j . containsAppData || j . containsObbs ) {
869+ GotoStep ( 4 )
870+ } else {
871+ GotoStep ( 5 )
872+ }
826873 }
827874 } )
828875 } )
876+ } else {
877+ GotoStep ( "4.1" )
829878 }
830- else TextBoxError ( "step4.1box" , j . msg )
831879 } )
832880 } )
833881}
@@ -1070,6 +1118,20 @@ document.getElementById("abortPassword").onclick = () => {
10701118 document . getElementById ( "confirmPassword" ) . style . display = "block"
10711119 CloseGetPasswordPopup ( )
10721120}
1121+
1122+ function RestoreBackup ( backupName , game ) {
1123+ if ( game && config . currentApp != game ) {
1124+ ChangeApp ( game )
1125+ setTimeout ( ( ) => RestoreBackupFromSelectedGame ( backupName ) , 200 )
1126+ return ;
1127+ }
1128+ RestoreBackupFromSelectedGame ( backupName )
1129+ }
1130+
1131+ function RestoreBackupFromSelectedGame ( backupName ) {
1132+ selectedBackup = backupName ;
1133+ OpenRestorePopup ( ) ;
1134+ }
10731135function PasswordInput ( ) {
10741136 TextBoxText ( "step7box" , "Waiting for response and requesting obbs to download from Oculus. This may take 30 seconds..." )
10751137 options . password = encodeURIComponent ( document . getElementById ( "passwordConfirm" ) . value )
@@ -1085,6 +1147,7 @@ function PasswordInput() {
10851147 TextBoxGood ( "step7box" , j . msg )
10861148 document . getElementById ( "abortPassword" ) . innerHTML = "Close Popup"
10871149 document . getElementById ( "confirmPassword" ) . style . display = "none"
1150+ OpenTab ( "download" )
10881151 }
10891152 } )
10901153 } )
@@ -1118,6 +1181,13 @@ document.getElementById("confirmLogin").onclick = () => {
11181181 TextBoxGood ( "step9box" , "One sec..." )
11191182 location = oculusLink
11201183}
1184+ document . getElementById ( "login2" ) . onclick = ( ) => {
1185+ TextBoxGood ( "step13box" , "One sec..." )
1186+ location = oculusLink
1187+ }
1188+ document . getElementById ( "abortLogin" ) . onclick = ( ) => {
1189+ CloseGetPasswordPopup ( )
1190+ }
11211191
11221192document . getElementById ( "tokenPassword" ) . onclick = ( ) => {
11231193 options . password = encodeURIComponent ( document . getElementById ( "passwordConfirm" ) . value )
0 commit comments