-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
76 lines (64 loc) · 2.78 KB
/
index.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Custom Bookmarklet Generator</title>
<style>
body { font-family: Arial, sans-serif; margin: 50px; }
label { display: block; margin-top: 15px; }
input[type="text"], input[type="email"] { width: 300px; padding: 8px; margin-top: 5px; }
button { margin-top: 20px; padding: 10px 20px; }
#bookmarklet-container { display: none; margin-top: 30px; }
#bookmarklet-link { padding: 10px 15px; background-color: #4CAF50; color: white; text-decoration: none; border-radius: 5px; }
#instructions { margin-top: 10px; }
</style>
</head>
<body>
<h1>Generate Your Custom Bookmarklet</h1>
<form id="bookmarklet-form">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<button type="submit">Generate Bookmarklet</button>
</form>
<div id="bookmarklet-container">
<h2>Your Bookmarklet:</h2>
<a href="#" id="bookmarklet-link" draggable="true">Invite Me!</a>
<p id="instructions">Drag the "Invite Me!" link above to your bookmarks bar.</p>
</div>
<script>
document.getElementById('bookmarklet-form').addEventListener('submit', function(e) {
e.preventDefault();
// Get user input
const name = document.getElementById('name').value.trim();
const email = document.getElementById('email').value.trim();
if (!name || !email) {
alert('Please enter both name and email.');
return;
}
// Use JSON.stringify to safely encode the strings
const nameEscaped = JSON.stringify(name);
const emailEscaped = JSON.stringify(email);
// Create the bookmarklet JavaScript code
const jsCode = `
javascript:
(function(){
document.querySelector('input[name="new_member_name"]').value=${nameEscaped};
document.querySelector('input[name="new_member_email"]').value=${emailEscaped};
document.querySelector('select[name="new_member_role"]').value="admin";
document.querySelector('button.primary.invite-member').click();
})();
`.replace(/\s+/g, ''); // Minify by removing whitespace
// Encode the entire JavaScript code for use in a URL
const bookmarklet = encodeURI(jsCode);
// Set the href of the bookmarklet link
const bookmarkletLink = document.getElementById('bookmarklet-link');
bookmarkletLink.href = bookmarklet;
bookmarkletLink.textContent = `Invite ${name}`;
// Show the bookmarklet container
document.getElementById('bookmarklet-container').style.display = 'block';
});
</script>
</body>
</html>