secret
Created

  • Download Gist
attachment-reminder.user.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// ==UserScript==
// @name Attachment forgetter preventer
// @namespace attachment-forgetter-preventer
// @description Prevent forgetting attachments
// @match http://code.google.com/p/chromium/issues/*
// @version 0.2
// ==/UserScript==
 
(function(document) {
document.addEventListener('submit', function(e) {
var comment = document.querySelector('textarea[name="comment"]');
if (comment && /attach/i.test(comment.value)) {
var allBlank = Array.prototype.every.call(
document.querySelectorAll('input[type="file"]'),
function(el) { return !el.value; });
if (allBlank && !confirm('It looks like you meant to attach something. Continue submitting?'))
e.preventDefault();
}
});
}(unsafeWindow.document));

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.