-
Notifications
You must be signed in to change notification settings - Fork 0
/
RedditAuth.html
37 lines (35 loc) · 1.32 KB
/
RedditAuth.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Reddit Authorisation Code</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
</head>
<body class="container">
<div class="text-center mt-4 card">
<div class="card-body">
<h1>Reddit Authorisation Code</h1>
<h2 id="heading">Hi <span id="username"></span>, your code is:
<pre><code id="code"></code></pre>
</h2>
<p>To link your account type:
<pre><code>/<span id="command">LinkReddit</span></code></pre>
</p>
</div>
</div>
<script>
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get('code');
const state = urlParams.get('state');
if (!(code || state)) {
document.getElementById("heading").hidden = true;
} else {
const state_arr = urlParams.get('state').split(",");
document.getElementById("username").innerHTML = state_arr[0];
document.getElementById("code").innerHTML = code;
document.getElementById("command").innerHTML = (state_arr.length > 1 ? state_arr[1] : "LinkReddit") + " " + code;
}
</script>
</body>
</html>