GusGold

MassRedditBan

Sep 4th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Anonymous function to keep globals cleaner
  2. (function(subreddit_id, accountsToBan, private_reason, public_note, ban_duration){
  3.     //create form elements for submitting the ban details
  4.     form = document.createElement("form");
  5.     action = document.createElement("input");
  6.     action.setAttribute("name", "action");
  7.     action.setAttribute("value", "add");
  8.     container = document.createElement("input");
  9.     container.setAttribute("name", "container");
  10.     container.setAttribute("value", subreddit_id);
  11.     type = document.createElement("input");
  12.     type.setAttribute("name", "type");
  13.     type.setAttribute("value", "banned");
  14.     names = document.createElement("input");
  15.     names.setAttribute("name", "name");
  16.     note = document.createElement("input");
  17.     note.setAttribute("name", "note");
  18.     note.setAttribute("value", public_note);
  19.     duration = document.createElement("input");
  20.     duration.setAttribute("name", "note");
  21.     duration.setAttribute("value", ban_duration);
  22.     ban_message = document.createElement("input");
  23.     ban_message.setAttribute("name", "note");
  24.     ban_message.setAttribute("value", private_reason);
  25.  
  26.     //add elements to form
  27.     form.appendChild(action);
  28.     form.appendChild(container);
  29.     form.appendChild(type);
  30.     form.appendChild(names);
  31.     form.appendChild(note);
  32.     form.appendChild(duration);
  33.     form.appendChild(ban_message);
  34.  
  35.     //Starting at the start is a good place to start
  36.     i = 0;
  37.  
  38.     function banUser(){
  39.         //setTimeout required for reddit's anti-spam method
  40.         setTimeout(function(){
  41.             console.log("Banning " + accountsToBan[i] + " (" + (i + 1) + " of " + accountsToBan.length + ")");
  42.             names.setAttribute("value", accountsToBan[i]);
  43.             post_form(form, "friend");
  44.             i++;
  45.             if(i < accountsToBan.length){
  46.                 //We all love recursion!
  47.                 banUser();
  48.             }
  49.         }, 1000);
  50.     }
  51.  
  52.     banUser();
  53. })(reddit.cur_site, ["array", "of", "accounts", "to", "ban"], "A private reason that is only shown to mods on the ban page", "A note that will be sent along with the ban message to the banned user", "duration (blank for permanent, else number of days)");
  54.  
  55. //Note that reddit.cur_site returns the fullname for the current subreddit. You shouldn't need to change it.
Advertisement
Add Comment
Please, Sign In to add comment