Simple script to extract a winner from your commenters
©
Today I share with you a simple script that you can use in contests to extract a winner chosen randomly from your commenters. The result is independent from how many times an account commented.
Here it is:
var comments = document.getElementById('#comments');
var commentsEntities = comments.querySelectorAll('a[class="ptc"]');
var allComments = Array.prototype.slice.call(commentsEntities);
var allCommenters = [...new Set(allComments.map(e => e.innerText.split(' ')[0]))];
var randomId = Math.floor(Math.random()*allCommenters.length-1)+1;
alert('The winner is... ' + allCommenters[randomId]);
To execute it all you have to do is open the browser console on the steemit page with your contest, paste the script and press enter. To re-run the extraction paste again the script and press enter.
(If you have a basic knowledge of javascript you can check yourself that this script is absolutely safe)
Enjoy! =)
Contest creators that may find this useful:
@rentmoney, @bunnypuncher, @flamingirl, @cryptogangz, @rufruf, @mikepm74, @zipsardinia, @follwoforupvotes, @viraldrome, @pundito, @playdice, ...
Thanks, I'm not a developer. I'm studying js to turn my contest into an automated bot. I'll try your script right away.
Ok @zipsardinia, let me know if it worked ok!
I did not test it on all browsers (but should be ok as it is).
Thanks =)
sei italiano! ho provato sia su frefox che su chrome. Mi da come vincitore sempre lo stesso.
@zipsardinia Yup, tu sardegna? ( :
Mm, strano dammi il post su cui l'hai provato. A me funziona sia su Chrome che su FF.
(chiaramente te sei escluso dall'estrazione quindi ci devono essere commenti di altri..)
Your name won't come out from the extraction, you need at least a comment from another user
E per verificare che utenti ha effettivamente trovato nei commenti puoi sempre digitare in console allCommenters e premere invio..
and if you want to verify which users were found in your comments just type allCommenters in the console and press enter
Funziona! Ho provato su questo post. Bravo! Alcune parti del codice non mi sono ancora chiare. Settimana prossima ho una lezione di js con un ragazzo che ho conosciuto qui. Spero presto di capirci qualcosa di più.
Good luck! =D
free resteemed follow upvote done by @michealclauri
upvote my comment please
Free resteem+ upvote courtesy of @untapentuoreja
Congratulations @gaottantacinque! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of comments received
Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
SteemitBoard and the Veterans on Steemit - The First Community Badge.
this is really nice
i will participate in this comment contest
@amritmahal this is not a contest. Here I only shared the script that anyone can use in their contest to extract a winner. : )
i check your service if your service is good i will participate next contest
@amritmahal this is not a contest. Here I only shared the script that anyone can use in their contest to extract a winner. : )
Flaged for multiple account spam, comment spam and tag spam.
the accounts of the spammer:
main account:
https://steemit.com/@gaottantacinque
spam accounts:
https://steemit.com/@gasaeightyfive
https://steemit.com/@marcocasario
https://steemit.com/@cribbio
automated comment spam:
https://steemit.com/@marcocasario/comments
our tags he is spamming:
#resteembot, #bestofresteembot, #winwithresteembot, #resteembotvip
@resteem.bot
Good stuff! =)