NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name HTML 5 USAMTS Upload Button // @namespace https://openuserjs.org/scripts/pi-plus-45x23/HTML_5_USAMTS_Upload_Button // @version 0.5 // @description Uses HTML 5 upload button instead of the default Flash // @author pi_Plus_45x23 // @downloadURL https://openuserjs.org/install/pi-plus-45x23/HTML_5_USAMTS_Upload_Button.user.js // @updateURL https://openuserjs.org/meta/pi-plus-45x23/HTML_5_USAMTS_Upload_Button.meta.js // @match http://usamts.org/MyUSAMTS/U_MySubmit.php // @match http://www.usamts.org/MyUSAMTS/U_MySubmit.php // @grant none // @require https://code.jquery.com/jquery-3.2.1.min.js // ==/UserScript== (function() { 'use strict'; if ($('form').length) { $('form').remove(); $('.usamtsbodytext').append($.parseHTML(`<form enctype="multipart/form-data"> <input name="Filedata" type="file" accept=".pdf"> <input type="hidden" value="Submit Query" name="Upload"> <input type="button" value="Upload">`)); $(':button').on('click', function() { var file = $(":file")[0].files[0]; if (file) { var name = file.name, type = file.name.match(/\.(.*)$/)[0], size = file.size, sid = document.cookie.substring(10); var input = document.createElement('input'); input.type = 'hidden'; input.name = 'Filename'; input.value = name; $('form').append(input); // Based on https://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously $.ajax({ // Your server script to process the upload url: 'U_Uploader.php?d=true&type=' + type + '&name=' + encodeURIComponent(name) + '&size=' + size + '&ft=pdf&sid=' + sid, type: 'POST', // Form data data: new FormData($('form')[0]), // Tell jQuery not to process data or worry about content-type // You *must* include these options! cache: false, contentType: false, processData: false, success: function() { window.location.href = 'U_Uploaded.php?name=' + name; } }); } }); } })();