I'm writing a Chrome plugin to modify the Facebook homepage.
How would I add an extra <li>
to the <ul>
with a class of _54nf
?
Here's my current code:
function addLabel()
{
var ul = document.getElementsByClassName("_54nf");
var li = document.createElement("li");
li.appendChild(document.createTextNode("Test"));
ul.appendChild(li); // line 6
}
addLabel();
The error I'm getting is:
Uncaught TypeError: undefined is not a function
I presume the problem is getElementsByClassName
but I'm not sure.