Created
May 5, 2018 09:41
-
-
Save Enmk/f22a88c3f726a673101ab426608f08ae to your computer and use it in GitHub Desktop.
Instagram Vote Count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var comments = document.getElementsByClassName("_ezgzd"); | |
| let op = ""; | |
| var total_votes = {'1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0}; | |
| for (let i = 0; i < comments.length; ++i) { | |
| let c = comments[i] | |
| if (c.textContent.length > 500 || c.firstChild.textContent == op) | |
| continue; | |
| let votes = c.children[1].textContent; | |
| votes = votes.replace(/[^\d]/g, ''); | |
| if (votes.length == 0) | |
| continue; | |
| // don't let vote for same option in the single comment twice | |
| let processed = {}; | |
| for (let j = 0; j < votes.length; ++j) { | |
| let vote = votes[j]; | |
| if (processed[vote] !== undefined) | |
| continue; | |
| total_votes[vote] += 1; | |
| } | |
| } | |
| console.log(total_votes); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment