|
88 | 88 | }
|
89 | 89 | </style>
|
90 | 90 |
|
91 |
| - <script> |
92 |
| - function encodeUsername(username) { |
93 |
| - return btoa(username); |
| 91 | +<script> |
| 92 | + function encodeUsername(username) { |
| 93 | + return btoa(username); |
| 94 | + } |
| 95 | + |
| 96 | + function decodeUsername(encodedUsername) { |
| 97 | + return atob(encodedUsername); |
| 98 | + } |
| 99 | + |
| 100 | + window.onload = async function () { |
| 101 | + try { |
| 102 | + if (localStorage.getItem('loggedIn') === 'true') { |
| 103 | + const username = localStorage.getItem('username'); |
| 104 | + |
| 105 | + document.getElementById('authSection').style.display = 'none'; |
| 106 | + document.getElementById('loggedInContent').style.display = 'block'; |
| 107 | + document.getElementById('welcomeMessage').textContent = `Welcome to your account, ${username}!`; |
| 108 | + |
| 109 | + const res = await fetch(`https://scratch-coding-hut.github.io/api/orders?username=${username}`); |
| 110 | + if (!res.ok) throw new Error('Failed to fetch order data'); |
| 111 | + |
| 112 | + const rawText = await res.text(); |
| 113 | + const json = JSON.parse(rawText); |
| 114 | + |
| 115 | + const completedOrders = json["completed-orders"] ?? "N/A"; |
| 116 | + const pendingOrders = json["pending-orders"] ?? "N/A"; |
| 117 | + |
| 118 | + document.getElementById('mainText').innerHTML = ` |
| 119 | + <p>Completed Orders: ${completedOrders}</p> |
| 120 | + <p>Pending Orders: ${pendingOrders}</p> |
| 121 | + <p>Raw Data:</p> |
| 122 | + <pre>${JSON.stringify(json, null, 2)}</pre> |
| 123 | + `; |
| 124 | + } else { |
| 125 | + await checkAuth(); |
| 126 | + } |
| 127 | + } catch (error) { |
| 128 | + console.error(error); |
| 129 | + document.getElementById('mainText').innerHTML = `<p>Something went wrong! Please try again later.</p>`; |
94 | 130 | }
|
| 131 | + }; |
95 | 132 |
|
96 |
| - function decodeUsername(encodedUsername) { |
97 |
| - return atob(encodedUsername); |
98 |
| - } |
| 133 | + async function checkAuth() { |
| 134 | + const PC = new URLSearchParams(window.location.search).get('privateCode'); |
99 | 135 |
|
100 |
| - window.onload = async function () { |
| 136 | + if (PC) { |
101 | 137 | try {
|
102 |
| - if (localStorage.getItem('loggedIn') === 'true') { |
103 |
| - |
104 |
| - const username = localStorage.getItem('username'); |
105 |
| - |
106 |
| - document.getElementById('authSection').style.display = 'none'; |
107 |
| - document.getElementById('loggedInContent').style.display = 'block'; |
108 |
| - document.getElementById('welcomeMessage').textContent = `Welcome to your account, ${username}!`; |
109 |
| - |
110 |
| - const res = await fetch(`https://scratch-coding-hut.github.io/api/orders?username=${username}`); |
111 |
| - if (!res.ok) throw new Error('Failed to fetch data'); |
112 |
| - |
113 |
| - const json = await res.json(); |
114 |
| - var completedorders = json[1].completed-orders; |
115 |
| - var pendingorders = json[1].pending-orders; |
116 |
| - document.getElementById('mainText').innerHTML = ` |
117 |
| - <p>Pending Orders: ${completedorders}</p> |
118 |
| - <p>Completed Orders: ${pendingorders}</p> |
119 |
| - <p>For Developers: ${json}</p> |
120 |
| - `; |
121 |
| - } else { |
122 |
| - await checkAuth(); |
123 |
| - } |
124 |
| - } catch (error) { |
125 |
| - console.error(error); |
126 |
| - document.getElementById('mainText').innerHTML = `<p>Something went wrong! Please try again later.</p>`; |
127 |
| - } |
128 |
| - }; |
129 |
| - |
130 |
| - async function checkAuth() { |
131 |
| - const PC = new URLSearchParams(window.location.search).get('privateCode'); |
132 |
| - |
133 |
| - if (PC) { |
134 |
| - try { |
135 |
| - const res = await fetch(`https://auth-api.itinerary.eu.org/auth/verifyToken/${PC}`); |
136 |
| - const data = await res.json(); |
137 |
| - const plainUsername = data.username; |
138 |
| - const encodedUsername = btoa(plainUsername); |
139 |
| - |
140 |
| - // Ban check (example logic) - Tested sucessfully by MyScratchedAccount - Banning bannie6 |
141 |
| - if (encodedUsername === 'YmFubmllNg==') { |
142 |
| - localStorage.removeItem('loggedIn'); |
143 |
| - localStorage.removeItem('username'); |
144 |
| - window.location.href = 'banscreen.html?reason=spam'; |
145 |
| - return; |
146 |
| - } |
147 |
| - |
148 |
| - localStorage.setItem('usernameEnc', encodedUsername); // encoded version |
149 |
| - localStorage.setItem('username', plainUsername); // plain version |
150 |
| - localStorage.setItem('loggedIn', 'true'); |
151 |
| - window.location.href = 'account.html'; |
152 |
| - } catch (err) { |
153 |
| - console.error('Token verification failed:', err); |
154 |
| - } |
155 |
| - } |
156 |
| - |
157 |
| - const DK = new URLSearchParams(window.location.search).get('devKey'); |
158 |
| - |
159 |
| - if (DK) { |
160 |
| - const devKey = new URLSearchParams(window.location.search).get('devKey'); |
161 |
| - |
162 |
| - if (devKey) { |
163 |
| - const username = atob(devKey) |
164 |
| - localStorage.setItem('usernameEnc', devKey); // Store the original Base64-encoded username |
165 |
| - localStorage.setItem('username', username); // Store the original Base64-encoded username |
166 |
| - localStorage.setItem('loggedIn', 'true'); |
167 |
| - window.location.href = 'account.html' |
| 138 | + const res = await fetch(`https://auth-api.itinerary.eu.org/auth/verifyToken/${PC}`); |
| 139 | + const data = await res.json(); |
| 140 | + const plainUsername = data.username; |
| 141 | + const encodedUsername = btoa(plainUsername); |
| 142 | + |
| 143 | + if (encodedUsername === 'YmFubmllNg==') { |
| 144 | + localStorage.removeItem('loggedIn'); |
| 145 | + localStorage.removeItem('username'); |
| 146 | + window.location.href = 'banscreen.html?reason=spam'; |
| 147 | + return; |
168 | 148 | }
|
169 | 149 |
|
| 150 | + localStorage.setItem('usernameEnc', encodedUsername); |
| 151 | + localStorage.setItem('username', plainUsername); |
| 152 | + localStorage.setItem('loggedIn', 'true'); |
| 153 | + window.location.href = 'account.html'; |
| 154 | + } catch (err) { |
| 155 | + console.error('Token verification failed:', err); |
170 | 156 | }
|
171 | 157 | }
|
172 | 158 |
|
173 |
| - function registerScratchAuth() { |
174 |
| - const messageBox = document.getElementById("scratchMessage"); |
175 |
| - const redirectLocation = btoa(window.location.href); |
176 |
| - const authUrl = `https://auth.itinerary.eu.org/auth?redirect=${redirectLocation}&name=Scratch%20Coding%20Hut`; |
177 |
| - |
178 |
| - messageBox.style.color = "green"; |
179 |
| - messageBox.textContent = "Redirecting to ScratchAuth... Follow the steps there."; |
180 |
| - setTimeout(() => { |
181 |
| - window.location.href = authUrl; |
182 |
| - }, 2000); |
183 |
| - } |
| 159 | + const DK = new URLSearchParams(window.location.search).get('devKey'); |
184 | 160 |
|
185 |
| - function logout() { |
186 |
| - localStorage.removeItem('loggedIn'); |
187 |
| - localStorage.removeItem('username'); |
188 |
| - localStorage.removeItem('usernameEnc'); |
| 161 | + if (DK) { |
| 162 | + const username = atob(DK); |
| 163 | + localStorage.setItem('usernameEnc', DK); |
| 164 | + localStorage.setItem('username', username); |
| 165 | + localStorage.setItem('loggedIn', 'true'); |
189 | 166 | window.location.href = 'account.html';
|
190 | 167 | }
|
191 |
| - |
192 |
| - function strikeinfo() { |
193 |
| - const username = localStorage.getItem('username'); |
194 |
| - if (username) { |
195 |
| - window.location.href = `https://scratch-coding-hut.github.io/Strikes/my-strikes?username=${username}`; |
196 |
| - } |
| 168 | + } |
| 169 | + |
| 170 | + function registerScratchAuth() { |
| 171 | + const messageBox = document.getElementById("scratchMessage"); |
| 172 | + const redirectLocation = btoa(window.location.href); |
| 173 | + const authUrl = `https://auth.itinerary.eu.org/auth?redirect=${redirectLocation}&name=Scratch%20Coding%20Hut`; |
| 174 | + |
| 175 | + messageBox.style.color = "green"; |
| 176 | + messageBox.textContent = "Redirecting to ScratchAuth... Follow the steps there."; |
| 177 | + setTimeout(() => { |
| 178 | + window.location.href = authUrl; |
| 179 | + }, 2000); |
| 180 | + } |
| 181 | + |
| 182 | + function logout() { |
| 183 | + localStorage.removeItem('loggedIn'); |
| 184 | + localStorage.removeItem('username'); |
| 185 | + localStorage.removeItem('usernameEnc'); |
| 186 | + window.location.href = 'account.html'; |
| 187 | + } |
| 188 | + |
| 189 | + function strikeinfo() { |
| 190 | + const username = localStorage.getItem('username'); |
| 191 | + if (username) { |
| 192 | + window.location.href = `https://scratch-coding-hut.github.io/Strikes/my-strikes?username=${username}`; |
197 | 193 | }
|
| 194 | + } |
198 | 195 |
|
199 |
| - function devToken() { |
200 |
| - const username = localStorage.getItem('username'); |
201 |
| - const devTokens = document.getElementById('devTokens'); |
| 196 | + function devToken() { |
| 197 | + const username = localStorage.getItem('username'); |
| 198 | + const devTokens = document.getElementById('devTokens'); |
202 | 199 |
|
203 |
| - if (username && devTokens) { |
204 |
| - const token = btoa(username); |
205 |
| - const joined = "Your dev token is: " + token + " - Make sure to only share it with Coding Hut services and partners or else you can get hacked!"; |
206 |
| - devTokens.style.color = "green"; |
207 |
| - devTokens.textContent = joined; |
208 |
| - } |
| 200 | + if (username && devTokens) { |
| 201 | + const token = btoa(username); |
| 202 | + const joined = "Your dev token is: " + token + " - Make sure to only share it with Coding Hut services and partners or else you can get hacked!"; |
| 203 | + devTokens.style.color = "green"; |
| 204 | + devTokens.textContent = joined; |
209 | 205 | }
|
210 |
| - </script> |
| 206 | + } |
| 207 | +</script> |
| 208 | + |
211 | 209 | </head>
|
212 | 210 |
|
213 | 211 | <body>
|
|
0 commit comments