Skip to content

Commit 8a4937c

Browse files
ComputerEliteComputerElite
authored andcommitted
FINALLY POG POG POG
1 parent 4df0187 commit 8a4937c

3 files changed

Lines changed: 68 additions & 44 deletions

File tree

Assets/html/index.html

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@
151151
</div>
152152
</div>
153153
</div>
154+
<div class="restoreStep" id="step8">
155+
<div class="contentHeader headerMargin">
156+
Password needed
157+
</div>
158+
Please enter a password to encrypt your login information (token). You can change this password any time by simply pressing the login button again in the tools & options tab.
159+
<input type="password" id="passwordToken" placeholder="password">
160+
<div id="step8box" class="textBox"></div>
161+
<div class="buttonSelectionContainer">
162+
<div class="buttonContainer buttonMargin">
163+
<div class="button" id="tokenPassword">Confirm password</div>
164+
</div>
165+
</div>
166+
</div>
154167
<div class="restoreStep" id="step9">
155168
<div class="contentHeader headerMargin">
156169
Login info
@@ -180,22 +193,6 @@
180193
</div>
181194
</div>
182195

183-
<div class="listContainer darken hidden" id="tokenPasswordContainer">
184-
<div class="restoreStep" id="step8">
185-
<div class="contentHeader headerMargin">
186-
Password needed
187-
</div>
188-
Please enter a password to encrypt your login information (token). You can change this password any time by simply pressing the login button again in the tools & options tab.
189-
<input type="password" id="passwordToken" placeholder="password">
190-
<div id="step8box" class="textBox"></div>
191-
<div class="buttonSelectionContainer">
192-
<div class="buttonContainer buttonMargin">
193-
<div class="button" id="tokenPassword">Confirm password</div>
194-
</div>
195-
</div>
196-
</div>
197-
</div>
198-
199196
<div class="listContainer darken hidden" id="deleteContainer">
200197
<div class="restoreStep" id="step6">
201198
<div class="contentHeader headerMargin">
@@ -303,26 +300,31 @@
303300
</div>
304301
</div>
305302
<script>
306-
fetch("/questappversionswitcher/loggedinstatus").then(res => {
307-
res.text().then(res => {
308-
if(res == "2") {
309-
// Logged in#
310-
document.getElementById("loggedInMsg").style.visibility = "visible"
311-
document.getElementById("downgradeLoginMsg").style.visibility = "hidden"
312-
} else {
313-
// Not logged in
314-
document.getElementById("loggedInMsg").style.visibility = "hidden"
315-
document.getElementById("downgradeLoginMsg").style.visibility = "visible"
316-
}
317-
})
318-
})
303+
319304
UpdateUI()
305+
const oculusLink = "https://auth.oculus.com/login/?redirect_uri=https%3A%2F%2Fsecure.oculus.com%2F&reason=page_require_login"
320306
const params = new URLSearchParams(window.location.search)
321307
var config = {}
322308
var selectedBackup = ""
323309

324310
var undefinedLoader = `<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>`
325311

312+
function TokenUIUpdate() {
313+
fetch("/questappversionswitcher/loggedinstatus").then(res => {
314+
res.text().then(res => {
315+
if(res == "2") {
316+
// Logged in#
317+
document.getElementById("loggedInMsg").style.visibility = "visible"
318+
document.getElementById("downgradeLoginMsg").style.visibility = "hidden"
319+
} else {
320+
// Not logged in
321+
document.getElementById("loggedInMsg").style.visibility = "hidden"
322+
document.getElementById("downgradeLoginMsg").style.visibility = "visible"
323+
}
324+
})
325+
})
326+
}
327+
326328
function UpdateUI(closeLists = false) {
327329
fetch("questappversionswitcher/config").then(res => res.json().then(res => {
328330
config = res
@@ -380,6 +382,10 @@
380382
GotoStep(10)
381383
}
382384

385+
if(params.get("loadoculus")) {
386+
location = oculusLink
387+
}
388+
383389
document.getElementById("login").onclick = () => {
384390
OpenGetPasswordPopup()
385391
GotoStep(9)
@@ -444,6 +450,9 @@
444450
document.getElementById("closeApp").onclick = () => {
445451
fetch("questappversionswitcher/kill")
446452
}
453+
document.getElementById("closeApp2").onclick = () => {
454+
fetch("questappversionswitcher/kill")
455+
}
447456
document.getElementById("confirmPort").onclick = () => {
448457
fetch("questappversionswitcher/changeport?body=" + document.getElementById("port").value).then(res => {
449458
res.text().then(text => {
@@ -659,14 +668,14 @@
659668
}
660669

661670
function CloseTokenPasswordPopup(done = false) {
662-
document.getElementById("tokenPasswordContainer").className = "listContainer darken hidden"
671+
document.getElementById("getPasswordContainer").className = "listContainer darken hidden"
663672
GotoStep(8)
664673
if (!done) CloseTokenPasswordPopup(true)
665674
}
666675

667676
function OpenTokenPasswordPopup() {
668677
CloseTokenPasswordPopup()
669-
document.getElementById("tokenPasswordContainer").className = "listContainer darken"
678+
document.getElementById("getPasswordContainer").className = "listContainer darken"
670679
}
671680

672681
function CloseGetPasswordPopup() {
@@ -708,7 +717,8 @@
708717
CloseGetPasswordPopup()
709718
}
710719
document.getElementById("confirmLogin").onclick = () => {
711-
location = "https://auth.oculus.com/login/?redirect_uri=https%3A%2F%2Fsecure.oculus.com%2F&reason=page_require_login"
720+
TextBoxGood("step9box", "One sec...")
721+
location = oculusLink
712722
}
713723

714724
document.getElementById("tokenPassword").onclick = () => {
@@ -724,6 +734,7 @@
724734
} else if (res.status == 200) {
725735
TextBoxGood("step8box", text)
726736
setTimeout(() => {
737+
TokenUIUpdate()
727738
CloseGetPasswordPopup()
728739
}, 5000)
729740
}

CoreVars.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class CoreVars // aka config
88
public string currentApp { get; set; } = "";
99
public int serverPort { get; set; } = 50002;
1010
public string token { get; set; } = "";
11-
public bool openLoginInstantly { get; set; } = false;
11+
public int loginStep { get; set; } = 0;
1212
public string password { get; set; } = "";
1313
public readonly string QAVSDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/";
1414
public readonly string QAVDTmpDowngradeDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/tmpDowngrade/";

WebServer.cs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,22 @@ public override void OnPageFinished(WebView view, string url)
3939
Logger.Log(url);
4040
if (url.Split("?")[0].Contains("oculus.com"))
4141
{
42+
if(CoreService.coreVars.loginStep == 2)
43+
{
44+
//Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
45+
MainThread.BeginInvokeOnMainThread(() =>
46+
{
47+
//view.EvaluateJavascript("document.body.innerHTML += `<div style=\"display: flex; align - items: center; justify - content: center; width: 100 %; height: 100vh; top: 0; left: 0; position: fixed; background - color: #000000aa;\" id=\"popup\"><div style=\"padding: 10px;border-radius: 5px;background-color: #424546;\"><div style=\"font-size: 130%;margin-bottom: 30px;margin-top: 40px;\">Almost there</div>Click the X in the bottom left to restart QuestAppVersionSwitcher a final time. After you restarted press the blue continue as ... button to log in</div></div>`", null);
48+
});
49+
}
4250
if (wasOnFacebook)
4351
{
4452
// Restart app here
45-
CoreService.coreVars.openLoginInstantly = true;
53+
CoreService.coreVars.loginStep = 1;
4654
CoreService.coreVars.Save();
4755
Thread t = new Thread(() =>
4856
{
49-
Thread.Sleep(1500);
57+
//Thread.Sleep(1500);
5058
MainThread.BeginInvokeOnMainThread(() =>
5159
{
5260
view.EvaluateJavascript("location = 'http://127.0.0.1:" + CoreService.coreVars.serverPort + "?restart=true'", null);
@@ -62,10 +70,6 @@ public override void OnPageFinished(WebView view, string url)
6270
{
6371
wasOnFacebook = true;
6472
}
65-
if (url.Contains("login-without-facebook"))
66-
{
67-
//view.EvaluateJavascript("alert(\"Accept the cookies. You'll be redirected to the login in 10 seconds\"); setTimeout(() => {location = 'https://auth.oculus.com/login/?redirect_uri=https%3A%2F%2Fsecure.oculus.com%2F'}, 10000)", null);
68-
}
6973
}
7074

7175
public static Dictionary<string, string> headers = new Dictionary<string, string>
@@ -87,12 +91,13 @@ public override WebResourceResponse ShouldInterceptRequest(WebView view, IWebRes
8791
if(!request.RequestHeaders.ContainsKey(p.Key)) request.RequestHeaders.Add(p.Key, p.Value);
8892
else request.RequestHeaders[p.Key] = p.Value;
8993
}
90-
if(request.Method == "POST")
94+
string cookie = CookieManager.Instance.GetCookie(request.Url.ToString());
95+
if (cookie != null) request.RequestHeaders["cookie"] = cookie;
96+
if (request.Method == "POST")
9197
{
9298
request.RequestHeaders["sec-fetch-mode"] = "cors";
9399
request.RequestHeaders["sec-fetch-dest"] = "empty";
94-
string cookie = CookieManager.Instance.GetCookie(request.Url.ToString());
95-
if (cookie != null) request.RequestHeaders["cookie"] = cookie;
100+
96101
}
97102
if(request.Url.Path.Contains("consent") && request.Url.Host.Contains("oculus"))
98103
{
@@ -660,11 +665,19 @@ public void Start()
660665
server.AddRouteFile("/facts.png", "facts.png");
661666
server.StartServer(CoreService.coreVars.serverPort);
662667
Thread.Sleep(1500);
663-
if (CoreService.coreVars.openLoginInstantly)
668+
if (CoreService.coreVars.loginStep == 1)
669+
{
670+
CoreService.coreVars.loginStep = 2;
671+
CoreService.coreVars.Save();
672+
//CoreService.browser.LoadUrl(CoreVars.oculusLoginUrl);
673+
CoreService.browser.LoadUrl("http://127.0.0.1:" + CoreService.coreVars.serverPort + "?loadoculus=true");
674+
}
675+
else if (CoreService.coreVars.loginStep == 2)
664676
{
665-
CoreService.coreVars.openLoginInstantly = false;
677+
CoreService.coreVars.loginStep = 0;
666678
CoreService.coreVars.Save();
667679
CoreService.browser.LoadUrl(CoreVars.oculusLoginUrl);
680+
CoreService.browser.LoadUrl("http://127.0.0.1:" + CoreService.coreVars.serverPort + "/");
668681
}
669682
else CoreService.browser.LoadUrl("http://127.0.0.1:" + CoreService.coreVars.serverPort + "/");
670683
}

0 commit comments

Comments
 (0)