this repo has no description
0
fork

Configure Feed

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

Linkify twitter usernames

This is due to some folks cross-posting from Twitter.

+17
+17
src/utils/enhance-content.js
··· 57 57 block.replaceWith(pre); 58 58 }); 59 59 60 + // TWITTER USERNAMES 61 + // ================= 62 + // Convert @username@twitter.com to <a href="https://twitter.com/username">@username@twitter.com</a> 63 + textNodes = extractTextNodes(dom); 64 + textNodes.forEach((node) => { 65 + let html = node.nodeValue.replace(/</g, '&lt;').replace(/>/g, '&gt;'); 66 + if (/@[a-zA-Z0-9_]+@twitter\.com/g.test(html)) { 67 + html = html.replaceAll( 68 + /(@([a-zA-Z0-9_]+)@twitter\.com)/g, 69 + '<a href="https://twitter.com/$2" rel="nofollow noopener noreferrer" target="_blank">$1</a>', 70 + ); 71 + } 72 + fauxDiv.innerHTML = html; 73 + const nodes = Array.from(fauxDiv.childNodes); 74 + node.replaceWith(...nodes); 75 + }); 76 + 60 77 if (postEnhanceDOM) { 61 78 postEnhanceDOM(dom); // mutate dom 62 79 }