this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Differentiate username displays

When there're mentions of multiple same username + different instances in a post

+15 -4
+15 -4
src/utils/enhance-content.js
··· 33 33 34 34 // Spanify un-spanned mentions 35 35 if (hasLink) { 36 - const notMentionLinks = Array.from(dom.querySelectorAll('a[href]')); 37 - notMentionLinks.forEach((link) => { 36 + const links = Array.from(dom.querySelectorAll('a[href]')); 37 + const usernames = []; 38 + links.forEach((link) => { 38 39 const text = link.innerText.trim(); 39 40 const hasChildren = link.querySelector('*'); 40 41 // If text looks like @username@domain, then it's a mention 41 42 if (/^@[^@]+(@[^@]+)?$/g.test(text)) { 42 43 // Only show @username 43 - const username = text.split('@')[1]; 44 - if (!hasChildren) link.innerHTML = `@<span>${username}</span>`; 44 + const [_, username, domain] = text.split('@'); 45 + if (!hasChildren) { 46 + if ( 47 + !usernames.find(([u]) => u === username) || 48 + usernames.find(([u, d]) => u === username && d === domain) 49 + ) { 50 + link.innerHTML = `@<span>${username}</span>`; 51 + usernames.push([username, domain]); 52 + } else { 53 + link.innerHTML = `@<span>${username}@${domain}</span>`; 54 + } 55 + } 45 56 link.classList.add('mention'); 46 57 } 47 58 // If text looks like #hashtag, then it's a hashtag