// ==UserScript==
// @name Gmail Show Attachments
// @namespace http://www.cs.toronto.edu/~james/google
// @description Don't hide gmail attachments when you save drafts
// @include http://gmail.google.com/gmail?view=page&name=js*
// @include https://gmail.google.com/gmail?view=page&name=js*
// @include http://mail.google.com/mail?view=page&name=js*
// @include https://mail.google.com/mail?view=page&name=js*
// ==/UserScript==

/* Created by David James
*/

        

(function() {
    var JS = top.js;
    if (JS && JS._IF_GetVisibleWindow && this == JS) {
        // Patch the Gmail code to always show attachments
        if (this.document.documentElement.innerHTML.match(/function\s*(\w+)[^\n]+CM_form\s*\[[^\]]+\]\s*=\s*(\w+)[^}]*return[^;]*\2/) ) {
            var initializeComposeWindow = this[RegExp.$1];
            var modifiedInitializeComposeWindow = function() {
                var newWindow = initializeComposeWindow.apply(this, modifiedInitializeComposeWindow.arguments);
                newWindow.inc_orig_attach = true;
                return newWindow;
            };
            this[RegExp.$1] = modifiedInitializeComposeWindow;
        }
    }
})();
