-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
64 lines (53 loc) · 2.3 KB
/
Copy pathscript.js
File metadata and controls
64 lines (53 loc) · 2.3 KB
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
document.addEventListener("DOMContentLoaded", () => {
const buttonSubmit = document.getElementById("save");
console.log(buttonSubmit);
// Attach an event listener to the form submission
buttonSubmit.addEventListener("click", (e) => {
e.preventDefault(); // Prevent page refresh
// Create a new Profile instance
const profile = new Profile();
// Loop through each property in the Profile class and populate it from the form
Object.keys(profile).forEach((key) => {
const input = document.getElementById(key);
if (input) {
profile[key] = input.value.trim(); // Get the input value and trim whitespace
}
});
// Save the profile to Chrome local storage
chrome.storage.local.set({ profile }, () => {
//alert("Profile saved successfully!");
console.log("Saved Profile:", profile); // For debugging
});
});
// const loadButton = document.getElementById("loadButton");
// const displayContainer = document.getElementById("profileDisplay"); // Where the profile data will be displayed
// // Add event listener for the button click
// loadButton.addEventListener("click", () => {
// // Retrieve the profile data from Chrome local storage
// chrome.storage.local.get(["profile"], (result) => {
// if (result.profile) {
// const profile = result.profile;
// // Clear any previous display
// displayContainer.innerHTML = "";
// // Dynamically display the profile fields and values
// for (const [key, value] of Object.entries(profile)) {
// const fieldDiv = document.createElement("div");
// fieldDiv.textContent = `${key}: ${value}`;
// displayContainer.appendChild(fieldDiv);
// }
// } else {
// displayContainer.innerHTML = "<p>No profile data found.</p>";
// }
// });
// });
});
document.addEventListener('DOMContentLoaded', () => {
const autoFillBtn = document.getElementById('autoFillBtn');
if (autoFillBtn) {
autoFillBtn.addEventListener('click', () => {
loadProfilePromise();
});
} else {
console.warn('Auto-Fill button with ID "autoFillBtn" not found.');
}
});