Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Anonymous function to keep globals cleaner
- (function(subreddit_id, accountsToBan, private_reason, public_note, ban_duration){
- //create form elements for submitting the ban details
- form = document.createElement("form");
- action = document.createElement("input");
- action.setAttribute("name", "action");
- action.setAttribute("value", "add");
- container = document.createElement("input");
- container.setAttribute("name", "container");
- container.setAttribute("value", subreddit_id);
- type = document.createElement("input");
- type.setAttribute("name", "type");
- type.setAttribute("value", "banned");
- names = document.createElement("input");
- names.setAttribute("name", "name");
- note = document.createElement("input");
- note.setAttribute("name", "note");
- note.setAttribute("value", public_note);
- duration = document.createElement("input");
- duration.setAttribute("name", "note");
- duration.setAttribute("value", ban_duration);
- ban_message = document.createElement("input");
- ban_message.setAttribute("name", "note");
- ban_message.setAttribute("value", private_reason);
- //add elements to form
- form.appendChild(action);
- form.appendChild(container);
- form.appendChild(type);
- form.appendChild(names);
- form.appendChild(note);
- form.appendChild(duration);
- form.appendChild(ban_message);
- //Starting at the start is a good place to start
- i = 0;
- function banUser(){
- //setTimeout required for reddit's anti-spam method
- setTimeout(function(){
- console.log("Banning " + accountsToBan[i] + " (" + (i + 1) + " of " + accountsToBan.length + ")");
- names.setAttribute("value", accountsToBan[i]);
- post_form(form, "friend");
- i++;
- if(i < accountsToBan.length){
- //We all love recursion!
- banUser();
- }
- }, 1000);
- }
- banUser();
- })(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)");
- //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