Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Reddit upvote /r/The_Donald
- // @namespace http://tampermonkey.net/
- // @version 0.2
- // @description Upvote /r/The_Donald
- // @author You
- // @match https://www.reddit.com/r/The_Donald*
- // @grant none
- // ==/UserScript==
- // Get children of siteTable into list.
- var threads = document.getElementById("siteTable");
- threads = threads.getElementsByClassName("link");
- var timer;
- var minTime = 1;
- var maxTime = 10;
- var i = 0;
- // Generate random timer for upvote
- function setTimer() {
- timer = Math.floor(Math.random() * 100 * 1000) / maxTime + minTime;
- }
- // Upvote thread
- function upvoteThread(thread) {
- // check for likes/unvoted element
- thread.getElementsByClassName("up")[0].click();
- }
- function setUpvoteTimeout() {
- while (i < threads.length) {
- if (threads[i].getElementsByClassName("upmod").length > 0) {
- i = i + 1;
- continue;
- }
- upvoteThread(threads[i]);
- i = i + 1;
- if (i < threads.length) {
- setTimer();
- window.setTimeout(setUpvoteTimeout, timer, threads[i]);
- }
- break;
- }
- }
- if (threads.length > 0) {
- setTimer();
- window.setTimeout(setUpvoteTimeout, setTimer());
- }
Add Comment
Please, Sign In to add comment