// ==UserScript== // @name 免Flash文件上传 // @name:en Upload without Flash // @namespace https://greasyfork.org/zh-CN/users/605474 // @version 0.1 // @description 无需调用Flash,从课程平台上传附件,不必为了传作业多装一个浏览器! // @description:en No need to call Flash, upload accessories from the course platform, do not have to make multiple browsers for the homework! // @author Ziu // @match *://cc.bjtu.edu.cn:81/* // @match *://cc.bjtu.edu.cn:81/meol/common/hw/student/write.jsp?hwtid=* // @icon https://gitee.com/ziuc/utool-filebed/raw/master//20210907-173652-0524.png // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; let frontTag = "
  • 上传作业
  • "; $('#tmenu').append(frontTag); let uploadBox = "
    上传附件:
    " $('.infotable:last>tbody>tr:first').after(uploadBox); // 文件点击上传 $('#currentFile').change(fileChangedByInput); // 文件拖拽上传 $('#inputArea').on('dragover',function(event){ event.preventDefault() }).on('drop',function(event){ event.preventDefault(); // 数据在event的dataTransfer对象中 for(let i=0;i[*]'+item.name+' ('+(item.size/1024).toFixed(2)+'KB)'+'

    上传进度:[0%]

    '); } else if(item.size>1000000&&item.size<1000000000){ $('#filenames').append('
    [*]'+item.name+' ('+(item.size/1048576).toFixed(2)+'MB)'+'

    上传进度:[0%]

    '); } } // 加上传按钮 $('#filenames').after("
    "); $('#buttonDiv').append("上传"); $('#uploadtrigger').click(function (){ // 构造请求 let oData = new FormData(); for(let i=0;idiv').length>=1){ $('#filenames').empty(); for(let i=0;i[*]'+item.name+' ('+(item.size/1024).toFixed(2)+'KB)'+'

    上传进度:[0%]

    '); } else if(item.size>1000000&&item.size<1000000000){ $('#filenames').append(''); } } $('#buttonDiv').remove(); } else { for(let i=0;i[*]'+item.name+' ('+(item.size/1024).toFixed(2)+'KB)'+'

    上传进度:[0%]

    '); } else if(item.size>1000000&&item.size<1000000000){ $('#filenames').append(''); } } $('#buttonDiv').remove(); } $('#filenames').after("
    "); $('#buttonDiv').append("上传"); $('#uploadtrigger').click(function (){ // 构造请求 let oData = new FormData(); for(let i=0;i[附件]

    ' // 遍历页面中iframe找到编辑器插入附件超链接 // 学习笔记中iframe为双层iframe嵌套 for(let i=0;i