Approve all your blog comment using javascript magic

I usually check and reply all my blog comments on friday night and approve the spam comments. Last friday I was checking my spam comments and saw that there was almost more than 70 comments and I thought approving all comments will be a hectic process and I was thinking of a process that I can do it with one click. Then I came up with the solution of writing a JavaScript script to approve all comments.

Here below the script –

var x = document.getElementsByClassName('comment__action comment__action-approve');
for (var i = 0; i < x.length; i++) {
    x[i].click();
}

The above code actually select the approve button and gives me an array then x[i].click(); this will click each approve button one by one.

Thank you 🙂

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s