Bureaucrats, Check users, Interface administrators, Push subscription managers, Suppressors, Administrators, upwizcampeditors
1,713
edits
No edit summary |
No edit summary |
||
Line 62: | Line 62: | ||
// find the person's name in the node, and surround their name (in the innerhtml) with a span and change the color to purple. Make sure that the name only exists in the text, and not in the html (so we don't change the color of the link) | // find the person's name in the node, and surround their name (in the innerhtml) with a span and change the color to purple. Make sure that the name only exists in the text, and not in the html (so we don't change the color of the link) | ||
var | var nodeText = node.textContent; | ||
// replace the node's | // Iterate through each user's name | ||
for (var j = 0; j < users.length; j++) { | |||
// this entire section was made by copilot | var userName = users[j]; | ||
// Create a regular expression to match the name in the text | |||
var regex = new RegExp('\\b' + userName + '\\b', 'g'); | |||
// Check if the user's name is present in the text | |||
if (nodeText.match(regex)) { | |||
// Create a new HTML string with the name wrapped in a <span> element | |||
var highlightedText = nodeText.replace(regex, '<span style="color: purple;">$&</span>'); | |||
// Update the node's HTML with the highlighted text | |||
node.innerHTML = highlightedText; | |||
} | |||
} | |||
// this entire section was made by copilot because im too lazy to do it myself | |||
} | } | ||
edits