Skip to content

Instantly share code, notes, and snippets.

@h3xx
Last active September 2, 2016 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h3xx/a1feaea70e1262a3530315a357701497 to your computer and use it in GitHub Desktop.
Save h3xx/a1feaea70e1262a3530315a357701497 to your computer and use it in GitHub Desktop.
// ==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