Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trigger a click on multiple elements with the same class

I'm trying to trigger a click on multiple elements with the same class but when i do so the first element only get clicked and not the others, frankly I'm trying to make likes to all ask.fm profile answers by using the console of firefox so this is what i did

$('.like').trigger('click');

but i realized that only the first element (answer) get clicked so i did something else

$('.like').each(function(){$(this).trigger('click');}) 

but the problem still exist, os what am i doing wrong here !!

Edit: The html code

all answers got this element in it

<a class="like hintable" hint="Like" href="#" onclick="Like.quickLike(128332156539, &quot;mo7am_rs&quot;, &quot;/likes/am77r/question/128332156539/add&quot;); return false;" style="display:block"></a>

and i want to click this element in all answers element

like image 455
MOHAMMAD RASIM Avatar asked May 25 '15 12:05

MOHAMMAD RASIM


1 Answers

Frankly I'm trying to make likes to all ask.fm profile answers

Your code should work, so, probably they're ignoring/blocking two too consecutive clicks to prevent bots and missclicks.

A workaround to this would be adding a sleep to it (you should adjust the sleep value, because it depends on their secret configured threshold).

The following code would try a click after each 10 seconds:

var sleep = 0;
$('.like').each(function(){
    var likeElement = $(this);
    setTimeout(function() {
        likeElement.trigger('click');
    }, sleep);
    sleep += 10000;
});

Please, also verify if that practice is compliant to the site's policy.

like image 82
falsarella Avatar answered Nov 10 '22 21:11

falsarella