Created
May 27, 2013 09:42
-
-
Save plexus/5656154 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
// 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