|
62 | 62 | color: white;
|
63 | 63 | }
|
64 | 64 | a.kRxZy-link {
|
65 |
| - color: #4CAF50; /* Green shade that blends well */ |
| 65 | + color: #4CAF50; |
66 | 66 | font-weight: bold;
|
67 | 67 | }
|
68 | 68 | a.kRxZy-link:hover {
|
|
72 | 72 | <script>
|
73 | 73 | // Generate a random 3-digit number
|
74 | 74 | function generateThreeDigitCode() {
|
75 |
| - return Math.floor(100 + Math.random() * 900); |
76 |
| - } |
| 75 | + return Math.floor(100 + Math.random() * 900); |
| 76 | + } |
| 77 | + |
| 78 | + let secretCode; |
77 | 79 | if (!localStorage.getItem('baseCode')) {
|
78 |
| - const secretCode = generateThreeDigitCode(); |
79 |
| - localStorage.setItem('baseCode', secretCode); |
| 80 | + secretCode = generateThreeDigitCode(); |
| 81 | + localStorage.setItem('baseCode', secretCode); |
80 | 82 | } else {
|
81 |
| - const secretCode = localStorage.getItem('baseCode'); |
82 |
| - } |
83 |
| - |
| 83 | + secretCode = localStorage.getItem('baseCode'); |
| 84 | + } |
84 | 85 |
|
85 | 86 | // Generate a key by shifting the baseKey based on the secret code
|
86 | 87 | function generateKeyFromCode(code) {
|
87 | 88 | const baseKey = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
88 | 89 | let shiftedKey = '';
|
89 |
| - let shift = parseInt(code) % 36; |
| 90 | + let shift = parseInt(code) % 36; |
90 | 91 | for (let i = 0; i < baseKey.length; i++) {
|
91 | 92 | shiftedKey += baseKey[(i + shift) % baseKey.length];
|
92 | 93 | }
|
|
102 | 103 | if (index !== -1) {
|
103 | 104 | encoded += key[index];
|
104 | 105 | } else {
|
105 |
| - encoded += char; |
| 106 | + encoded += char; |
106 | 107 | }
|
107 | 108 | }
|
108 | 109 | return encoded;
|
109 | 110 | }
|
110 | 111 |
|
111 | 112 | // On page load, check if the user is logged in
|
112 |
| - window.onload = function() { |
| 113 | + window.onload = function () { |
113 | 114 | if (localStorage.getItem('loggedIn') === 'true') {
|
114 | 115 | const username = localStorage.getItem('username');
|
115 | 116 | const textElements = document.querySelectorAll('.text');
|
116 | 117 | const loggedIn = document.getElementById('loggedIn');
|
117 | 118 | const tlogged = document.getElementById('textForLogged');
|
118 | 119 |
|
119 | 120 | // Hide all elements with the class "text"
|
120 |
| - textElements.forEach(function(element) { |
| 121 | + textElements.forEach(function (element) { |
121 | 122 | element.style.display = 'none';
|
122 | 123 | });
|
123 | 124 |
|
|
135 | 136 | const urlParams = new URLSearchParams(window.location.search);
|
136 | 137 | const authSuccess = urlParams.get('success');
|
137 | 138 | const username = urlParams.get('username');
|
138 |
| - |
| 139 | + |
139 | 140 | if (username) {
|
140 | 141 | const key = generateKeyFromCode(secretCode);
|
141 | 142 | const encodedUsername = encodeUsername(username.toLowerCase(), key);
|
@@ -195,28 +196,25 @@ <h2>Welcome! Please log in to continue.</h2>
|
195 | 196 | <button onclick="registerScratchAuth()">Sign In With ScratchAuth</button>
|
196 | 197 | <p id="scratchMessage" class="message" aria-live="polite"></p>
|
197 | 198 | <p>
|
198 |
| - Please note: You will be redirected to an external site (ScratchAuth) for authentication. Once there, |
| 199 | + Please note: You will be redirected to an external site (ScratchAuth) for authentication. Once there, |
199 | 200 | choose the "Cloud Data" option for the quickest sign-in method.
|
200 |
| - |
201 |
| - If you are unable to use the "Cloud Data" option, other sign-in methods are available on Scratch Auth's page, for example, profile commenting. |
202 | 201 | </p>
|
203 | 202 | </div>
|
204 | 203 |
|
205 | 204 | <!-- APIAuth Section -->
|
206 | 205 | <div class="text container">
|
207 | 206 | <h2>Login Using APIAuth</h2>
|
208 |
| - <button onclick="registerApiAuth()">Login With APIAuth (Made by |
| 207 | + <button onclick="registerApiAuth()">Login With APIAuth (Made by |
209 | 208 | <a href="https://scratch.mit.edu/users/kRxZy_kRxZy/" target="_blank" class="kRxZy-link">kRxZy_kRxZy</a>)</button>
|
210 | 209 | <p id="apiMessage" class="message" aria-live="polite"></p>
|
211 | 210 | <p>
|
212 | 211 | APIAuth, made by <a href="https://scratch.mit.edu/users/kRxZy_kRxZy/" target="_blank" class="kRxZy-link">kRxZy_kRxZy</a>, is the next generation of Scratch Authentication.
|
213 |
| - You only need to enter your username, put a code in your bio, click Done, and then remove the code. Then, you are logged in. |
214 | 212 | </p>
|
215 | 213 | </div>
|
216 | 214 |
|
217 | 215 | <!-- Report Issue Section -->
|
218 | 216 | <div class="text container">
|
219 |
| - <a href="https://github.com/Scratch-Coding-Hut/Scratch-Coding-Hut.github.io/issues/new"> |
| 217 | + <a href="https://github.com/Scratch-Coding-Hut/Scratch-Coding-Hut.github.io/issues/new"> |
220 | 218 | <button>Having trouble signing in? Report an issue</button>
|
221 | 219 | </a>
|
222 | 220 | </div>
|
|
0 commit comments