mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
added user address highlighting
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
function handleAddressClick(shortAddress) {
|
||||
const isMobile = window.innerWidth <= 480;
|
||||
const addressSelector = isMobile ? '.address-mobile' : '.address-desktop';
|
||||
const postReplySelector = isMobile ? '.post-reply-mobile' : '.post-reply-desktop';
|
||||
const opSelector = isMobile ? '.op-mobile' : '.op-desktop';
|
||||
|
||||
const matchingElements = [...document.querySelectorAll(postReplySelector + ',' + opSelector)].filter(el => {
|
||||
const addressElement = el.querySelector(addressSelector);
|
||||
return addressElement && addressElement.textContent.includes(shortAddress);
|
||||
});
|
||||
|
||||
if (matchingElements.length === 0) {
|
||||
console.log('Could not find any matching elements');
|
||||
return;
|
||||
}
|
||||
|
||||
const highlightedElements = document.querySelectorAll('.highlighted');
|
||||
highlightedElements.forEach(el => {
|
||||
el.classList.remove('highlighted');
|
||||
});
|
||||
|
||||
matchingElements.forEach(el => {
|
||||
if (!el.classList.contains('op-mobile') && !el.classList.contains('op-desktop')) {
|
||||
el.classList.add('highlighted');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default handleAddressClick;
|
||||
Reference in New Issue
Block a user