Skip to content

Instantly share code, notes, and snippets.

@danbeam
Created February 26, 2013 00:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save danbeam/55c45021e1ce268edfaf to your computer and use it in GitHub Desktop.
Save danbeam/55c45021e1ce268edfaf to your computer and use it in GitHub Desktop.
// ==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));
@abrahamseed
Copy link

<script src="https://gist.github.com/danbeam/55c45021e1ce268edfaf.js"></script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment