Bureaucrats, Check users, Interface administrators, Push subscription managers, Suppressors, Administrators, upwizcampeditors
1,713
edits
No edit summary |
No edit summary |
||
Line 61: | Line 61: | ||
var node = nodes.snapshotItem(i); | var node = nodes.snapshotItem(i); | ||
// find the person's name in the node, and surround | // 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 name = node. | var name = node.innerHTML.match(/^(.*?)\s/)[1]; | ||
var | var nameIndex = node.innerHTML.indexOf(name); | ||
var nameLength = name.length; | |||
var html = node.innerHTML; | |||
var text = node.textContent; | |||
var textIndex = text.indexOf(name); | |||
var textLength = name.length; | |||
var startTag = '<span style="color:purple">'; | |||
var endTag = '</span>'; | |||
var htmlStart = html.substring(0, nameIndex); | |||
var htmlEnd = html.substring(nameIndex + nameLength); | |||
var textStart = text.substring(0, textIndex); | |||
var textEnd = text.substring(textIndex + textLength); | |||
var newHtml = htmlStart + startTag + html.substring(nameIndex, nameIndex + nameLength) + endTag + htmlEnd; | |||
// replace the node's innerHTML with the new html | |||
node.innerHTML = newHtml; | |||
// this entire section was made by copilot cuz im too lazy to do it myself | |||
} | } | ||
edits