Skip to content

Instantly share code, notes, and snippets.

@plexus
Created May 27, 2013 09:42
Show Gist options
  • Save plexus/5656154 to your computer and use it in GitHub Desktop.
Save plexus/5656154 to your computer and use it in GitHub Desktop.
// In code climate, when you mark a security warning as being a false positive,
// You get redirected to the security dashboard. This is extremely annoying when
// there's a whole category of alerts that are false positives. Run this in your
// browser console to add an alternative button that does the POST in the background
// so you stay on the same page.
function adapt_form(idx) {
var button = $('<a>Move to false positives</a>')[0]
var form = this;
$(button).click(
function(){
submit_form.call(form);
$(form).parent().parent().slideUp();
}
);
$(this).prepend(button);
}
function submit_form(idx) {
var action = this['action'];
var token = $(this).find('input[name=authenticity_token]')[0]['value'];
$.post(action, {'authenticity_token': token});
};
$('form').each(adapt_form);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment