I'm trying to make a script for Greasemonkey to automatically pin when a Pinterest window is opened.
CODE:
body = document.body;
if (body != null) {
var prepare = document.getElementsByTagName("button");
var buttons = "";
for (var i = 0; i < prepare.length; i++){
if (prepare[i].getAttribute("data-text-pin-it")!=null) {
buttons = prepare[i];
break;
}
}
buttons.click();
}
It gets executed, if I set a console.log at the end of the code is printed, but the button is not clicked!
If I execute the same instructions by Firebug console I get the desired effect.