Skip to content

Instantly share code, notes, and snippets.

@h3xx h3xx/REDDIT-modwarning.js
Last active Sep 2, 2016

Embed
What would you like to do?
// ==UserScript==
// @name REDDIT-modwarning
// @namespace reddit
// @include http://www.reddit.com/r/*/comments/*
// @include https://www.reddit.com/r/*/comments/*
// @require https://code.jquery.com/jquery-2.2.4.min.js
// @version 0.02
// ==/UserScript==
(function () {
var button_defs = [
{
buttonText: 'Rule 4',
message: function (vars) {
return "/u/" + vars.OP + ": Hello. Your post has been removed for breaking " +
"Rule 4. You have previously broken our rules here:\n\n\n\n" +
"In line with our 'three strikes' policy, if you break any of our rules again you will be permanently banned from our subreddit.";
}
},
{
buttonText: 'Rule 6',
message: function (vars) {
return "/u/" + vars.OP + ": Hello. Your post has been removed for breaking " +
"[Rule 6](http://www.reddit.com/r/mildlyinteresting/comments/21p15y/rule_6_for_dummies/). You have previously broken our rules here:\n\n\n\n" +
"In line with our 'three strikes' policy, if you break any of our rules again you will be permanently banned from our subreddit.";
}
}
];
function addModButton(buttonText, message) {
var $modbutton = $('<div>').text(buttonText);
$modbutton.css({
'float': 'left',
'border': '1px solid black',
'background-color': 'white',
'margin': '5px 5px 10px 0',
'padding': '4px',
'cursor': 'pointer'
});
$modbutton.on('click', function () {
if (typeof message === 'function') {
var vars = {
'OP': $('.entry .tagline .author').first().text()
};
message = message(vars);
}
$('textarea[name=text]').first().val(message);
});
$('.usertext-edit').append($modbutton);
}
$(function () {
$(button_defs).each(function () {
addModButton(this.buttonText, this.message);
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.