-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dotMavriQ
committed
Oct 3, 2024
1 parent
b10ac58
commit b707c3f
Showing
2 changed files
with
37 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,41 @@ | ||
// popup.js | ||
// Handle the "Save" button click event | ||
document.getElementById("save").addEventListener("click", () => { | ||
const originalName = document.getElementById("original-name").value.trim(); | ||
const newName = document.getElementById("new-name").value.trim(); | ||
const messageElement = document.getElementById("message"); | ||
|
||
document.getElementById('save').addEventListener('click', () => { | ||
const originalName = document.getElementById('original-name').value.trim(); | ||
const newName = document.getElementById('new-name').value.trim(); | ||
const messageElement = document.getElementById('message'); | ||
if (originalName && newName) { | ||
// Get existing overrides from storage | ||
chrome.storage.sync.get("chatRoomOverrides", (data) => { | ||
const overrides = data.chatRoomOverrides || {}; | ||
overrides[originalName] = newName; | ||
|
||
if (originalName && newName) { | ||
// Get existing overrides from storage | ||
chrome.storage.sync.get('chatRoomOverrides', (data) => { | ||
const overrides = data.chatRoomOverrides || {}; | ||
overrides[originalName] = newName; | ||
// Save the new override | ||
chrome.storage.sync.set({ chatRoomOverrides: overrides }, () => { | ||
messageElement.textContent = "Name override saved!"; | ||
messageElement.style.color = "#b8bb26"; // Gruvbox green | ||
|
||
// Save the new override | ||
chrome.storage.sync.set({ chatRoomOverrides: overrides }, () => { | ||
messageElement.textContent = 'Name override saved!'; | ||
messageElement.style.color = '#b8bb26'; // Gruvbox green | ||
// Clear input fields | ||
document.getElementById("original-name").value = ""; | ||
document.getElementById("new-name").value = ""; | ||
}); | ||
}); | ||
} else { | ||
// Show error message | ||
messageElement.textContent = "Please fill out both fields."; | ||
messageElement.style.color = "#fb4934"; // Gruvbox red | ||
} | ||
}); | ||
|
||
// Clear input fields | ||
document.getElementById('original-name').value = ''; | ||
document.getElementById('new-name').value = ''; | ||
}); | ||
}); | ||
} else { | ||
// Show error message | ||
messageElement.textContent = 'Please fill out both fields.'; | ||
messageElement.style.color = '#fb4934'; // Gruvbox red | ||
} | ||
// Handle the "Clear All Tacks" button click event | ||
document.getElementById("clear-all").addEventListener("click", () => { | ||
// Confirm with the user before clearing | ||
if (window.confirm("Are you sure you want to clear all tacks?")) { | ||
// Clear all overrides from storage | ||
chrome.storage.sync.remove("chatRoomOverrides", () => { | ||
const messageElement = document.getElementById("message"); | ||
messageElement.textContent = "All tacks have been cleared!"; | ||
messageElement.style.color = "#b8bb26"; // Gruvbox green | ||
}); | ||
} | ||
}); |