-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathredirect.html
57 lines (56 loc) · 1.66 KB
/
redirect.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="TemplateData/favicon.ico" type="image/x-icon" />
<title>Redirect</title>
</head>
<body>
The window will automatically close.
</body>
<script defer>
window.addEventListener("DOMContentLoaded", function () {
var currentURL = window.location.href;
var endindex;
var message;
var Iserror = false;
var Type = currentURL
.substring(
currentURL.indexOf("state=") + "state=".length,
currentURL.indexOf("-TheColors")
)
.toString();
var startIndex =
currentURL.indexOf("access_token=") + "access_token=".length;
switch (Type) {
case "Google":
endindex = currentURL.indexOf("&token_type");
break;
case "Facebook":
endindex = currentURL.indexOf("&data_access_expiration_time");
break;
case "Zalo" :
startIndex = currentURL.indexOf("code=") + "code=".length;
endindex = currentURL.indexOf("&state");
break;
case "Twitch":
endindex = currentURL.indexOf("&scope");
break;
case "Discord":
endindex = currentURL.indexOf("&expires_in");
break;
default:
Iserror = true;
break;
}
if (Iserror == false) {
message = currentURL.substring(startIndex, endindex);
window.opener.postMessage(Type + " " + message, "*");
} else {
console.log("not found state");
}
window.close();
});
</script>
</html>