I know how to create a button with userscript, but I don't know how to attach a function to the button with userscript. How do I attach a function to the button with userscript? I would also like to add an "id" to the button with userscript. How do I do that? Thanks.
var button = document.createElement("BUTTON"); // Create a <button> element
var text = document.createTextNode("CLICK ME"); // Create a text node
button.appendChild(text); // Append the text to <button>
document.body.appendChild(button);
function clickMe() {
alert("Hi");
} //end of function clickMe()