Created
December 14, 2015 18:41
-
-
Save fflexo/557bcda9704a0c157798 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name More flag decline options | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match http://stackoverflow.com/admin/dashboard* | |
// @grant none | |
// ==/UserScript== | |
/* jshint -W097 */ | |
'use strict'; | |
// Make our own copy of jQuery... | |
var $, jQuery; | |
$ = jQuery = window.jQuery; | |
// This is starting to make the size of the dialog unweildly large. Probably best bet is to nest the messages (e.g. create a tree of options) rather than display all at once | |
var messages = [ | |
"Please don't use a custom moderator flag where one of the pre-written flags is sufficient", | |
"Deleting your question now would unfairly penalise those who freely gave their time to help you and prevent future readers from benefiting from their answers", | |
"It would be better to fix the issues in the question through editing and salvage it now rather than deleting", | |
"Once credentials have been leaked and cached/indexed by search engines the only course of action which can rescue the situation is for the OP to invalidate them" | |
]; | |
// This is clunky, the way it works is by hooking clicks to 'local' messages and then populating the "other" option with them instead | |
$(document).ajaxComplete(function(e, jqXHR, ajaxOptions, data) { | |
if (ajaxOptions.url.match(/^\/admin\/dismiss-flag/)) { | |
var list = $('ul.action-list'); | |
var extra = $(); | |
$.each(messages, function(i,m) { | |
extra = extra.add('<li style="width: 380px"><label><input name="dismiss_Options" id="extra_100'+i+'" type="radio" value="100'+i+'" style="float: left"><span class="action-desc">'+m+'</span></label></li>'); | |
}); | |
extra.click(function(e) { | |
e.preventDefault(); | |
$('input#dis_Alt', list).click(); | |
$('input#dis_comment', list).val($('span.action-desc', $(this)).text()); | |
}); | |
extra.insertBefore($('li', list).last()); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment