-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
31 lines (24 loc) · 1010 Bytes
/
content.js
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
// content.js
// Function to override chatroom names
function overrideChatroomNames() {
// Load saved overrides from Chrome storage
chrome.storage.sync.get("chatRoomOverrides", (data) => {
const overrides = data.chatRoomOverrides || {};
// Select all channel names in the sidebar
document.querySelectorAll('.p-channel_sidebar__name').forEach((element) => {
const originalName = element.innerText.trim();
// Check if there's an override for this chatroom name
if (overrides[originalName]) {
element.innerText = overrides[originalName];
}
});
});
}
// Run the override function on initial load
overrideChatroomNames();
// Set up a MutationObserver to catch changes in the chatroom list (dynamic updates)
const observer = new MutationObserver(() => {
overrideChatroomNames();
});
// Start observing changes in the document body
observer.observe(document.body, { childList: true, subtree: true });