Dooratre commited on
Commit
cb42e0d
·
verified ·
1 Parent(s): 48f2e42

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +191 -55
index.html CHANGED
@@ -3,7 +3,7 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>API Signup Form</title>
7
  <style>
8
  body {
9
  font-family: Arial, sans-serif;
@@ -31,9 +31,8 @@
31
  margin-bottom: 5px;
32
  font-weight: bold;
33
  }
34
- input[type="text"],
35
  input[type="email"],
36
- input[type="password"] {
37
  width: 100%;
38
  padding: 10px;
39
  border: 1px solid #ccc;
@@ -62,84 +61,221 @@
62
  white-space: pre-wrap;
63
  word-wrap: break-word;
64
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  </style>
66
  </head>
67
  <body>
68
  <div class="container">
69
- <h1>Signup Form</h1>
70
- <form id="signupForm">
71
- <div class="form-group">
72
- <label for="username">Username:</label>
73
- <input type="text" id="username" name="username" required>
74
- </div>
75
  <div class="form-group">
76
  <label for="email">Email:</label>
77
- <input type="email" id="email" name="email" required>
78
- </div>
79
- <div class="form-group">
80
- <label for="password">Password:</label>
81
- <input type="password" id="password" name="password" required>
82
  </div>
 
 
 
 
 
 
83
  <div class="form-group">
84
- <label for="send_confirmation_code">Send Confirmation Code:</label>
85
- <input type="checkbox" id="send_confirmation_code" name="send_confirmation_code" checked>
86
  </div>
87
- <button type="submit">Submit</button>
88
- </form>
 
89
  <div class="response-box" id="responseBox">
90
- <!-- Response will be displayed here -->
91
  </div>
92
  </div>
93
 
94
  <script>
95
- document.getElementById('signupForm').addEventListener('submit', async function (e) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  e.preventDefault(); // Prevent default form submission
97
 
98
- // Get form data
99
- const formData = {
100
- username: document.getElementById('username').value,
101
- email: document.getElementById('email').value,
102
- password: document.getElementById('password').value,
103
- send_confirmation_code: document.getElementById('send_confirmation_code').checked,
104
- p102xyzname: "" // Static value as per the original code
105
- };
106
-
107
- // API URL
108
- const url = "https://api.puter.com/signup";
109
-
110
- // Headers
111
- const headers = {
112
- "Accept-Language": "en-US,en;q=0.9",
113
- "X-Requested-With": "XMLHttpRequest",
114
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
115
- "Accept": "*/*",
116
- "Content-Type": "application/json",
117
- "Origin": "https://puter.com",
118
- "Referer": "https://puter.com/",
119
- "Connection": "keep-alive"
120
- };
121
 
122
  try {
123
- // Make the POST request
124
- const response = await fetch(url, {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  method: 'POST',
126
  headers: headers,
127
- body: JSON.stringify(formData)
128
  });
129
 
130
- // Check if the response is OK (status code 200-299)
131
- if (!response.ok) {
132
- throw new Error(`HTTP error! Status: ${response.status}`);
133
  }
134
 
135
- // Parse the response as JSON
136
- const jsonResponse = await response.json();
137
 
138
- // Display the JSON response in the box
139
- document.getElementById('responseBox').textContent = `Status Code: ${response.status}\nResponse: ${JSON.stringify(jsonResponse, null, 2)}`;
140
  } catch (error) {
141
- // Handle errors and display them in the response box
142
- document.getElementById('responseBox').textContent = `Error: ${error.message}`;
 
143
  }
144
  });
145
  </script>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Auto Account Creation</title>
7
  <style>
8
  body {
9
  font-family: Arial, sans-serif;
 
31
  margin-bottom: 5px;
32
  font-weight: bold;
33
  }
 
34
  input[type="email"],
35
+ input[type="text"] {
36
  width: 100%;
37
  padding: 10px;
38
  border: 1px solid #ccc;
 
61
  white-space: pre-wrap;
62
  word-wrap: break-word;
63
  }
64
+ .confirmation-form {
65
+ margin-top: 20px;
66
+ display: none;
67
+ }
68
+ .loading {
69
+ text-align: center;
70
+ margin: 10px 0;
71
+ display: none;
72
+ }
73
+ .loading:after {
74
+ content: '.';
75
+ animation: dots 1.5s steps(5, end) infinite;
76
+ }
77
+ @keyframes dots {
78
+ 0%, 20% { content: '.'; }
79
+ 40% { content: '..'; }
80
+ 60% { content: '...'; }
81
+ 80%, 100% { content: ''; }
82
+ }
83
  </style>
84
  </head>
85
  <body>
86
  <div class="container">
87
+ <h1>Auto Account Creation</h1>
88
+ <form id="accountForm">
 
 
 
 
89
  <div class="form-group">
90
  <label for="email">Email:</label>
91
+ <input type="email" id="email" name="email" required placeholder="Enter your email">
 
 
 
 
92
  </div>
93
+ <button type="submit">Create Account</button>
94
+ </form>
95
+
96
+ <div class="loading" id="loadingIndicator">Processing</div>
97
+
98
+ <div class="confirmation-form" id="confirmationForm">
99
  <div class="form-group">
100
+ <label for="confirmationCode">Enter confirmation code sent to your email:</label>
101
+ <input type="text" id="confirmationCode" name="confirmationCode" required placeholder="Enter confirmation code">
102
  </div>
103
+ <button type="button" id="confirmButton">Confirm Email</button>
104
+ </div>
105
+
106
  <div class="response-box" id="responseBox">
107
+ <!-- Responses will be displayed here -->
108
  </div>
109
  </div>
110
 
111
  <script>
112
+ // Function to generate a random username (7-15 letters and numbers)
113
+ function generateUsername() {
114
+ const length = Math.floor(Math.random() * (15 - 7 + 1)) + 7;
115
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
116
+ let username = '';
117
+ for (let i = 0; i < length; i++) {
118
+ username += characters.charAt(Math.floor(Math.random() * characters.length));
119
+ }
120
+ return username;
121
+ }
122
+
123
+ // Function to generate a random password meeting the criteria
124
+ function generatePassword() {
125
+ const length = Math.floor(Math.random() * (16 - 8 + 1)) + 8;
126
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()';
127
+ let password = '';
128
+ let hasUpper = false, hasLower = false, hasDigit = false, hasSpecial = false;
129
+
130
+ while (!hasUpper || !hasLower || !hasDigit || !hasSpecial) {
131
+ password = '';
132
+ for (let i = 0; i < length; i++) {
133
+ const char = characters.charAt(Math.floor(Math.random() * characters.length));
134
+ password += char;
135
+
136
+ if (/[A-Z]/.test(char)) hasUpper = true;
137
+ if (/[a-z]/.test(char)) hasLower = true;
138
+ if (/[0-9]/.test(char)) hasDigit = true;
139
+ if (/[\!\@\#\$\%\^\&\*\(\)]/.test(char)) hasSpecial = true;
140
+ }
141
+ }
142
+ return password;
143
+ }
144
+
145
+ // Global variables to store account info
146
+ let accountToken = '';
147
+ let accountPassword = '';
148
+
149
+ document.getElementById('accountForm').addEventListener('submit', async function (e) {
150
  e.preventDefault(); // Prevent default form submission
151
 
152
+ // Clear response box and show loading indicator
153
+ const responseBox = document.getElementById('responseBox');
154
+ const loadingIndicator = document.getElementById('loadingIndicator');
155
+ responseBox.textContent = '';
156
+ loadingIndicator.style.display = 'block';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  try {
159
+ // Step 1: Generate random username and password
160
+ const email = document.getElementById('email').value;
161
+ const username = generateUsername();
162
+ const password = generatePassword();
163
+ accountPassword = password; // Store for later use
164
+
165
+ responseBox.textContent += `Generated Username: ${username}\nGenerated Password: ${password}\n\n`;
166
+
167
+ // Step 2: Sign up API call
168
+ const signupUrl = "https://api.puter.com/signup";
169
+ const signupHeaders = {
170
+ "Accept-Language": "en-US,en;q=0.9",
171
+ "X-Requested-With": "XMLHttpRequest",
172
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
173
+ "Accept": "*/*",
174
+ "Content-Type": "application/json",
175
+ "Origin": "https://puter.com",
176
+ "Referer": "https://puter.com/",
177
+ "Connection": "keep-alive"
178
+ };
179
+ const signupData = {
180
+ username,
181
+ email,
182
+ password,
183
+ send_confirmation_code: true,
184
+ p102xyzname: ""
185
+ };
186
+
187
+ const signupResponse = await fetch(signupUrl, {
188
+ method: 'POST',
189
+ headers: signupHeaders,
190
+ body: JSON.stringify(signupData)
191
+ });
192
+
193
+ if (!signupResponse.ok) {
194
+ throw new Error(`Signup failed with status: ${signupResponse.status}`);
195
+ }
196
+
197
+ const signupDataJson = await signupResponse.json();
198
+ accountToken = signupDataJson.token;
199
+ responseBox.textContent += `Signup Successful!\n\n`;
200
+ responseBox.textContent += `Please check your email for the confirmation code.\n\n`;
201
+
202
+ // Show confirmation form
203
+ document.getElementById('confirmationForm').style.display = 'block';
204
+ loadingIndicator.style.display = 'none';
205
+ } catch (error) {
206
+ responseBox.textContent += `Error: ${error.message}`;
207
+ loadingIndicator.style.display = 'none';
208
+ }
209
+ });
210
+
211
+ // Handle confirmation code submission
212
+ document.getElementById('confirmButton').addEventListener('click', async function() {
213
+ const confirmCode = document.getElementById('confirmationCode').value.trim();
214
+ const responseBox = document.getElementById('responseBox');
215
+ const loadingIndicator = document.getElementById('loadingIndicator');
216
+
217
+ if (!confirmCode) {
218
+ responseBox.textContent += "Error: Confirmation code is required.\n\n";
219
+ return;
220
+ }
221
+
222
+ loadingIndicator.style.display = 'block';
223
+
224
+ try {
225
+ const confirmEmailUrl = "https://api.puter.com/confirm-email";
226
+ const headers = {
227
+ "Accept-Language": "en-US,en;q=0.9",
228
+ "X-Requested-With": "XMLHttpRequest",
229
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
230
+ "Accept": "*/*",
231
+ "Content-Type": "application/json",
232
+ "Origin": "https://puter.com",
233
+ "Referer": "https://puter.com/",
234
+ "Connection": "keep-alive",
235
+ "Authorization": `Bearer ${accountToken}`
236
+ };
237
+ const confirmEmailData = { code: confirmCode };
238
+
239
+ const confirmEmailResponse = await fetch(confirmEmailUrl, {
240
+ method: 'POST',
241
+ headers: headers,
242
+ body: JSON.stringify(confirmEmailData)
243
+ });
244
+
245
+ if (!confirmEmailResponse.ok) {
246
+ throw new Error(`Email confirmation failed with status: ${confirmEmailResponse.status}`);
247
+ }
248
+
249
+ const confirmEmailDataJson = await confirmEmailResponse.json();
250
+ if (!confirmEmailDataJson.email_confirmed) {
251
+ throw new Error("Email confirmation failed.");
252
+ }
253
+
254
+ responseBox.textContent += "Email confirmed successfully.\n\n";
255
+
256
+ // Step 4: Delete account
257
+ const deleteAccountUrl = "https://api.puter.com/delete-own-user";
258
+ const deleteAccountData = { password: accountPassword };
259
+
260
+ const deleteAccountResponse = await fetch(deleteAccountUrl, {
261
  method: 'POST',
262
  headers: headers,
263
+ body: JSON.stringify(deleteAccountData)
264
  });
265
 
266
+ if (!deleteAccountResponse.ok) {
267
+ throw new Error(`Account deletion failed with status: ${deleteAccountResponse.status}`);
 
268
  }
269
 
270
+ const deleteAccountDataJson = await deleteAccountResponse.json();
271
+ responseBox.textContent += "Account deleted successfully.";
272
 
273
+ // Hide confirmation form after completion
274
+ document.getElementById('confirmationForm').style.display = 'none';
275
  } catch (error) {
276
+ responseBox.textContent += `Error: ${error.message}`;
277
+ } finally {
278
+ loadingIndicator.style.display = 'none';
279
  }
280
  });
281
  </script>