I try to write a JS code that press the Subscribe button from a Youtube Subscribe Form.
Here is a link to a Youtube Subscribe form: http://www.youtube.com/subscribe_widget?p=aaaa
I tried this:
document.getElementById("subscribe-button").getElementsByTagName("button")[0].click();
But it gave me this error:
/*
Exception: document.getElementById("subscribe-button") is null
@Scratchpad:1
*/
This is the button HTML code:
<button role="button" id="subscribe-button" class="action-initiator yt-uix-button yt-uix-button-default" type="button" onclick="controller.subscribe(null);return false;"><span class="yt-uix-button-content">Subscribe </span></button>
How can I do this?
You could call click() instantly