// ==UserScript== // @name 免Flash文件上传 // @namespace https://greasyfork.org/zh-CN/users/605474 // @version 1.4.0 // @description 无需调用Flash,从课程平台上传附件,不必为了传作业多装一个浏览器! // @author ZiuChen // @source https://github.com/ZiuChen/NO-FLASH-Upload // @match *://cc.bjtu.edu.cn:81/* // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js // @require https://cdn.bootcdn.net/ajax/libs/jquery/1.7.2/jquery.min.js // @require https://cdn.bootcdn.net/ajax/libs/clipboard.js/2.0.8/clipboard.min.js // @icon https://gitee.com/ziuc/utool-filebed/raw/master/20210514-231824-0795.png // @license MIT // @name:en NO-FLASH-Upload // @description:en No need to call Flash, upload accessories from the course platform, do not have to install another browser for the homework! // @downloadURL none // ==/UserScript== /******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ "./node_modules/css-loader/dist/runtime/api.js": /***/ ((module) => { /* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ module.exports = function (cssWithMappingToString) { var list = []; // return the list of modules as css string list.toString = function toString() { return this.map(function (item) { var content = ""; var needLayer = typeof item[5] !== "undefined"; if (item[4]) { content += "@supports (".concat(item[4], ") {"); } if (item[2]) { content += "@media ".concat(item[2], " {"); } if (needLayer) { content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {"); } content += cssWithMappingToString(item); if (needLayer) { content += "}"; } if (item[2]) { content += "}"; } if (item[4]) { content += "}"; } return content; }).join(""); }; // import a list of modules into the list list.i = function i(modules, media, dedupe, supports, layer) { if (typeof modules === "string") { modules = [[null, modules, undefined]]; } var alreadyImportedModules = {}; if (dedupe) { for (var k = 0; k < this.length; k++) { var id = this[k][0]; if (id != null) { alreadyImportedModules[id] = true; } } } for (var _k = 0; _k < modules.length; _k++) { var item = [].concat(modules[_k]); if (dedupe && alreadyImportedModules[item[0]]) { continue; } if (typeof layer !== "undefined") { if (typeof item[5] === "undefined") { item[5] = layer; } else { item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}"); item[5] = layer; } } if (media) { if (!item[2]) { item[2] = media; } else { item[1] = "@media ".concat(item[2], " {").concat(item[1], "}"); item[2] = media; } } if (supports) { if (!item[4]) { item[4] = "".concat(supports); } else { item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}"); item[4] = supports; } } list.push(item); } }; return list; }; /***/ }), /***/ "./node_modules/css-loader/dist/runtime/noSourceMaps.js": /***/ ((module) => { module.exports = function (i) { return i[1]; }; /***/ }), /***/ "./node_modules/css-loader/dist/cjs.js!./src/style/css/PopNotify.css": /***/ ((module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./node_modules/css-loader/dist/runtime/noSourceMaps.js"); /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./node_modules/css-loader/dist/runtime/api.js"); /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__); // Imports var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default())); // Module ___CSS_LOADER_EXPORT___.push([module.id, "/**\r\n PopNotify.css\r\n @author CKylinMC\r\n @version 1.1\r\n @license MIT\r\n*/\r\n\r\ndiv.popNotifyUnitFrame {\r\n cursor: pointer;\r\n box-shadow: 0 3px 6px #80808085;\r\n min-width: 300px;\r\n position: fixed;\r\n z-index: 9999;\r\n width: max-content;\r\n min-height: 60px;\r\n height: fit-content;\r\n text-align: left;\r\n top: -100%;\r\n right: -100%;\r\n /* overflow: hidden; */\r\n opacity: 1;\r\n background: white;\r\n border-radius: 6px;\r\n /* animation: pnin forwards .3s cubic-bezier(0, 0.6, 0, 1); */\r\n /* animation: pnin forwards .8s cubic-bezier(0.04, 1.01, 0.17, 1.04); */\r\n animation: pnin forwards .8s cubic-bezier(0.1, 1, 0, 1.05);\r\n transition: .3s;\r\n /*padding: 6px 12px;*/\r\n overflow: hidden;\r\n}\r\n\r\ndiv.popNotifyUnitFrame>*:not(i):nth-child(1) {\r\n margin-bottom: 0;\r\n}\r\n\r\ndiv.popNotifyUnitFrame>*:not(i):nth-child(2) {\r\n margin-top: 0;\r\n}\r\n\r\n.popNotifyUnitTitle,\r\n.popNotifyUnitContent {\r\n transform: translateX(50px);\r\n opacity: 0;\r\n min-height: 30px;\r\n height: fit-content;\r\n margin: 6px 12px;\r\n font-size: 1em;\r\n}\r\n\r\n.popNotifyUnitTitle {\r\n font-weight: bold;\r\n font-size: 1.5em;\r\n}\r\n\r\n.popNotifyUnitBar {\r\n display: block;\r\n position: absolute;\r\n left: 0;\r\n bottom: 0;\r\n height: 3px;\r\n width: 0%;\r\n background: black;\r\n animation-name: pnbar;\r\n animation-timing-function: linear;\r\n}\r\n\r\n.popStyle-success {\r\n background: rgb(172, 255, 223)!important;\r\n}\r\n\r\n.popStyle-success .popNotifyUnitTitle,\r\n.popStyle-success .popNotifyUnitContent {\r\n color: rgb(0, 114, 70) !important;\r\n}\r\n\r\n.popStyle-success .popNotifyUnitBar {\r\n background: rgb(0, 114, 70) !important;\r\n}\r\n\r\n.popStyle-info {\r\n background: rgb(195, 226, 255) !important;\r\n}\r\n\r\n.popStyle-info .popNotifyUnitTitle,\r\n.popStyle-info .popNotifyUnitContent {\r\n color: rgb(0, 80, 155) !important;\r\n}\r\n\r\n.popStyle-info .popNotifyUnitBar {\r\n background: rgb(0, 80, 155) !important;\r\n}\r\n\r\n.popStyle-error {\r\n background: rgb(255, 196, 196) !important;\r\n}\r\n\r\n.popStyle-error .popNotifyUnitTitle,\r\n.popStyle-error .popNotifyUnitContent {\r\n color: rgb(255, 66, 66) !important;\r\n}\r\n\r\n.popStyle-error .popNotifyUnitBar {\r\n background: rgb(255, 66, 66) !important;\r\n}\r\n\r\n.popStyle-warn {\r\n background: rgb(255, 218, 139) !important;\r\n}\r\n\r\n.popStyle-warn .popNotifyUnitTitle,\r\n.popStyle-warn .popNotifyUnitContent {\r\n color: rgb(177, 94, 0) !important;\r\n}\r\n\r\n.popStyle-warn .popNotifyUnitBar {\r\n background: rgb(177, 94, 0) !important;\r\n}\r\n\r\n@keyframes pnin {\r\n from {\r\n opacity: 0;\r\n right: -100%;\r\n }\r\n /* to {\r\n opacity: 1;\r\n right: 20px;\r\n } */\r\n}\r\n\r\n@keyframes pnout {\r\n to {\r\n opacity: 0;\r\n right: -100%;\r\n }\r\n}\r\n\r\n@keyframes pntextin {\r\n to {\r\n opacity: 1;\r\n transform: translateX(0);\r\n }\r\n}\r\n\r\n@keyframes pnbar {\r\n to {\r\n width: 100%;\r\n }\r\n}", ""]); // Exports /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___); /***/ }), /***/ "./node_modules/css-loader/dist/cjs.js!./src/style/css/reminderCSS.css": /***/ ((module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./node_modules/css-loader/dist/runtime/noSourceMaps.js"); /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./node_modules/css-loader/dist/runtime/api.js"); /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__); // Imports var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default())); // Module ___CSS_LOADER_EXPORT___.push([module.id, ".top {\r\n font-weight: bold;\r\n}\r\n\r\n.hwtName,\r\n.courseName {\r\n font-size: 105%;\r\n cursor: pointer;\r\n}\r\n\r\n.listwrap>.list {\r\n overflow: auto;\r\n height: 150px;\r\n}", ""]); // Exports /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___); /***/ }), /***/ "./node_modules/css-loader/dist/cjs.js!./src/style/css/upload-doms.css": /***/ ((module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./node_modules/css-loader/dist/runtime/noSourceMaps.js"); /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./node_modules/css-loader/dist/runtime/api.js"); /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__); // Imports var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default())); // Module ___CSS_LOADER_EXPORT___.push([module.id, "/*\r\n upload-doms.css\r\n @author ZiuChen\r\n*/\r\n\r\nbody {\r\n font-family: PingFang SC,HarmonyOS_Regular,Helvetica Neue,Microsoft YaHei,sans-serif!important;\r\n font-weight: 400;\r\n background-color: #F1F2F3;\r\n}\r\n\r\n#inputDiv {\r\n height: 200px;\r\n width: 560px;\r\n margin-top: 20px;\r\n margin-bottom: 10px;\r\n box-shadow: 5px 5px 5px #888888;\r\n cursor: pointer;\r\n border: 4px solid;\r\n border-radius: 10px;\r\n border-color: #82b900;\r\n background: #c6f062;\r\n}\r\n\r\n#currentFile {\r\n display: none;\r\n}\r\n\r\n#filenames {\r\n height: 200px;\r\n overflow: auto;\r\n margin-top: 10px;\r\n margin-bottom: 10px;\r\n border: 3px solid rgb(130, 185, 0);\r\n box-shadow: 5px 5px 5px #888888;\r\n border-radius: 10px;\r\n -moz-user-select: none;\r\n\t-webkit-user-select: none;\r\n\t-ms-user-select: none;\r\n\tuser-select: none;\r\n}\r\n\r\n/* 滚动条 */\r\n#filenames::-webkit-scrollbar {\r\n width: 12px;\r\n}\r\n/* 滚动槽 */\r\n#filenames::-webkit-scrollbar-track {\r\n border-radius: 10px;\r\n}\r\n/* 滑块 */\r\n#filenames::-webkit-scrollbar-thumb {\r\n border-radius: 10px;\r\n background: rgba(0,0,0,0.1);\r\n}\r\n\r\n#filenames::-webkit-scrollbar-thumb:active {\r\n border-radius: 10px;\r\n background: rgba(0,0,0,0.4);\r\n}\r\n\r\n#buttonDiv {\r\n margin-top: 20px;\r\n margin-bottom: 10px;\r\n text-align: center;\r\n -moz-user-select: none;\r\n\t-webkit-user-select: none;\r\n\t-ms-user-select: none;\r\n\tuser-select: none;\r\n}\r\n\r\n#outerDiv {\r\n font-size: 14px;\r\n width: 590px;\r\n margin: 0 auto;\r\n margin-top: 5px;\r\n margin-bottom: 5px;\r\n}\r\n\r\n#fileInfo {\r\n text-align: left;\r\n cursor: default;\r\n}\r\n\r\n#textShow {\r\n margin-top: 80px;\r\n font-size: 20px;\r\n color: #424d55;\r\n text-align: center;\r\n}\r\n\r\n#userTips {\r\n color: #c0c1bb;\r\n cursor: default;\r\n}\r\n\r\n#buttonDiv>a {\r\n cursor: pointer;\r\n padding-top: 5.5px;\r\n padding-bottom: 5.5px;\r\n padding-right: 12px;\r\n padding-left: 12px;\r\n margin-right: 12px;\r\n margin-left: 12px;\r\n border-radius: 5px;\r\n box-shadow: 1px 1px 3px #888888;\r\n background-color: #c6f062;\r\n border: 2px solid;\r\n}\r\n\r\n.fileObjects {\r\n cursor:default;\r\n margin-top: 10px;\r\n margin-bottom: 10px;\r\n background-image: url(\"http://cc.bjtu.edu.cn:81/meol/styles/newstyle/course/new06/body_bg.jpg\");\r\n background-repeat:no-repeat;\r\n background-size: 0%;\r\n}", ""]); // Exports /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___); /***/ }), /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js": /***/ ((module) => { var stylesInDOM = []; function getIndexByIdentifier(identifier) { var result = -1; for (var i = 0; i < stylesInDOM.length; i++) { if (stylesInDOM[i].identifier === identifier) { result = i; break; } } return result; } function modulesToDom(list, options) { var idCountMap = {}; var identifiers = []; for (var i = 0; i < list.length; i++) { var item = list[i]; var id = options.base ? item[0] + options.base : item[0]; var count = idCountMap[id] || 0; var identifier = "".concat(id, " ").concat(count); idCountMap[id] = count + 1; var indexByIdentifier = getIndexByIdentifier(identifier); var obj = { css: item[1], media: item[2], sourceMap: item[3], supports: item[4], layer: item[5] }; if (indexByIdentifier !== -1) { stylesInDOM[indexByIdentifier].references++; stylesInDOM[indexByIdentifier].updater(obj); } else { var updater = addElementStyle(obj, options); options.byIndex = i; stylesInDOM.splice(i, 0, { identifier: identifier, updater: updater, references: 1 }); } identifiers.push(identifier); } return identifiers; } function addElementStyle(obj, options) { var api = options.domAPI(options); api.update(obj); var updater = function updater(newObj) { if (newObj) { if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) { return; } api.update(obj = newObj); } else { api.remove(); } }; return updater; } module.exports = function (list, options) { options = options || {}; list = list || []; var lastIdentifiers = modulesToDom(list, options); return function update(newList) { newList = newList || []; for (var i = 0; i < lastIdentifiers.length; i++) { var identifier = lastIdentifiers[i]; var index = getIndexByIdentifier(identifier); stylesInDOM[index].references--; } var newLastIdentifiers = modulesToDom(newList, options); for (var _i = 0; _i < lastIdentifiers.length; _i++) { var _identifier = lastIdentifiers[_i]; var _index = getIndexByIdentifier(_identifier); if (stylesInDOM[_index].references === 0) { stylesInDOM[_index].updater(); stylesInDOM.splice(_index, 1); } } lastIdentifiers = newLastIdentifiers; }; }; /***/ }), /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js": /***/ ((module) => { var memo = {}; /* istanbul ignore next */ function getTarget(target) { if (typeof memo[target] === "undefined") { var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) { try { // This will throw an exception if access to iframe is blocked // due to cross-origin restrictions styleTarget = styleTarget.contentDocument.head; } catch (e) { // istanbul ignore next styleTarget = null; } } memo[target] = styleTarget; } return memo[target]; } /* istanbul ignore next */ function insertBySelector(insert, style) { var target = getTarget(insert); if (!target) { throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid."); } target.appendChild(style); } module.exports = insertBySelector; /***/ }), /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js": /***/ ((module) => { /* istanbul ignore next */ function insertStyleElement(options) { var element = document.createElement("style"); options.setAttributes(element, options.attributes); options.insert(element, options.options); return element; } module.exports = insertStyleElement; /***/ }), /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js": /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /* istanbul ignore next */ function setAttributesWithoutAttributes(styleElement) { var nonce = true ? __webpack_require__.nc : 0; if (nonce) { styleElement.setAttribute("nonce", nonce); } } module.exports = setAttributesWithoutAttributes; /***/ }), /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js": /***/ ((module) => { /* istanbul ignore next */ function apply(styleElement, options, obj) { var css = ""; if (obj.supports) { css += "@supports (".concat(obj.supports, ") {"); } if (obj.media) { css += "@media ".concat(obj.media, " {"); } var needLayer = typeof obj.layer !== "undefined"; if (needLayer) { css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {"); } css += obj.css; if (needLayer) { css += "}"; } if (obj.media) { css += "}"; } if (obj.supports) { css += "}"; } var sourceMap = obj.sourceMap; if (sourceMap && typeof btoa !== "undefined") { css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */"); } // For old IE /* istanbul ignore if */ options.styleTagTransform(css, styleElement, options.options); } function removeStyleElement(styleElement) { // istanbul ignore if if (styleElement.parentNode === null) { return false; } styleElement.parentNode.removeChild(styleElement); } /* istanbul ignore next */ function domAPI(options) { var styleElement = options.insertStyleElement(options); return { update: function update(obj) { apply(styleElement, options, obj); }, remove: function remove() { removeStyleElement(styleElement); } }; } module.exports = domAPI; /***/ }), /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js": /***/ ((module) => { /* istanbul ignore next */ function styleTagTransform(css, styleElement) { if (styleElement.styleSheet) { styleElement.styleSheet.cssText = css; } else { while (styleElement.firstChild) { styleElement.removeChild(styleElement.firstChild); } styleElement.appendChild(document.createTextNode(css)); } } module.exports = styleTagTransform; /***/ }), /***/ "./package.json": /***/ ((module) => { module.exports = JSON.parse('{"name":"no-flash-upload","description":"一个北京交通大学课程平台附件上传脚本。","version":"1.3.9","author":{"name":"ZiuChen","email":"ZiuChen@outlook.com"},"scripts":{"postversion":"git push --follow-tags","analize":"npm_config_report=true npm run build","build":"webpack --mode production --config config/webpack.config.production.cjs","dev":"webpack --mode development --config config/webpack.config.dev.cjs"},"repository":{"type":"git","url":"https://github.com/ZiuChen/NO-FLASH-Upload"},"private":true,"dependencies":{"axios":"0.24.0","axios-userscript-adapter":"0.1.8","jquery":"3.6.0"},"devDependencies":{"@babel/core":"7.16.0","@babel/preset-env":"7.16.0","@babel/preset-typescript":"7.16.0","@types/greasemonkey":"4.0.2","@typescript-eslint/eslint-plugin":"5.2.0","@typescript-eslint/parser":"5.2.0","babel-loader":"8.2.3","browserslist":"4.17.5","css-loader":"6.5.0","less":"4.1.2","less-loader":"10.2.0","style-loader":"3.3.1","typescript":"4.4.4","userscript-metadata-webpack-plugin":"0.1.1","webpack":"5.61.0","webpack-bundle-analyzer":"4.5.0","webpack-cli":"4.9.1","webpack-livereload-plugin":"3.0.2","webpack-merge":"5.8.0"}}'); /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ id: moduleId, /******/ // no module.loaded needed /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ /******/ /* webpack/runtime/compat get default export */ /******/ (() => { /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = (module) => { /******/ var getter = module && module.__esModule ? /******/ () => (module['default']) : /******/ () => (module); /******/ __webpack_require__.d(getter, { a: getter }); /******/ return getter; /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/define property getters */ /******/ (() => { /******/ // define getter functions for harmony exports /******/ __webpack_require__.d = (exports, definition) => { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) /******/ })(); /******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. (() => { ;// CONCATENATED MODULE: ./src/functions/append-tags/front-tags.js let Tag1 = /*html*/ `
  • 上传作业
  • `; let Tag2 = /*html*/ `
  • 下载资源
  • `; /* harmony default export */ const front_tags = ({ tag1: Tag1, tag2: Tag2 }); ;// CONCATENATED MODULE: ./src/functions/append-tags/append-tags.js function apppendTags() { $('#tmenu').append(front_tags.tag1, front_tags.tag2); } /* harmony default export */ const append_tags = (apppendTags); ;// CONCATENATED MODULE: ./src/functions/file-upload/tips-blow.js let tips = { p1: /*html*/ `

    Tips:上传前点击文件前的图标可以删除该文件,文件上传后点击文件名获取文件下载链接。

    `, p2: /*html*/ `

    感谢您使用此脚本,欢迎好评推荐给身边同学,

    `, p3: /*html*/ `

    如果喜欢这个脚本,可以选择捐赠,这将鼓励我持续维护这个脚本。

    ` }; /* harmony default export */ const tips_blow = (tips); ;// CONCATENATED MODULE: ./src/functions/file-upload/upload-doms.js let inputDiv = /* html */ `

    📁文件上传📝

    (支持拖拽上传文件)

    `; let inputTag = /* html */ ``; let fileInfoDiv = /* html */ `
    已选择文件:
    `; let filenamesDiv = /* html */ `
    `; let uploadBtn = /* html */ `上传`; let emptyBtn = /* html */ `清空`; let buttonDiv = /* html */ `
    ${uploadBtn}${emptyBtn}
    `; let usertipsDiv = /* html */ `
    ${tips_blow.p1}${tips_blow.p2}${tips_blow.p3}更多信息
    `; let uploadBox = /* html */ `
    ${inputDiv}${inputTag}${fileInfoDiv}${filenamesDiv}${buttonDiv}${usertipsDiv}
    `; /* harmony default export */ const upload_doms = ({ box: uploadBox, uploadBtn: uploadBtn, emptyBtn: emptyBtn }); // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js var injectStylesIntoStyleTag = __webpack_require__("./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"); var injectStylesIntoStyleTag_default = /*#__PURE__*/__webpack_require__.n(injectStylesIntoStyleTag); // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleDomAPI.js var styleDomAPI = __webpack_require__("./node_modules/style-loader/dist/runtime/styleDomAPI.js"); var styleDomAPI_default = /*#__PURE__*/__webpack_require__.n(styleDomAPI); // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertBySelector.js var insertBySelector = __webpack_require__("./node_modules/style-loader/dist/runtime/insertBySelector.js"); var insertBySelector_default = /*#__PURE__*/__webpack_require__.n(insertBySelector); // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js var setAttributesWithoutAttributes = __webpack_require__("./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"); var setAttributesWithoutAttributes_default = /*#__PURE__*/__webpack_require__.n(setAttributesWithoutAttributes); // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertStyleElement.js var insertStyleElement = __webpack_require__("./node_modules/style-loader/dist/runtime/insertStyleElement.js"); var insertStyleElement_default = /*#__PURE__*/__webpack_require__.n(insertStyleElement); // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleTagTransform.js var styleTagTransform = __webpack_require__("./node_modules/style-loader/dist/runtime/styleTagTransform.js"); var styleTagTransform_default = /*#__PURE__*/__webpack_require__.n(styleTagTransform); // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./src/style/css/PopNotify.css var PopNotify = __webpack_require__("./node_modules/css-loader/dist/cjs.js!./src/style/css/PopNotify.css"); ;// CONCATENATED MODULE: ./src/style/css/PopNotify.css var options = {}; options.styleTagTransform = (styleTagTransform_default()); options.setAttributes = (setAttributesWithoutAttributes_default()); options.insert = insertBySelector_default().bind(null, "head"); options.domAPI = (styleDomAPI_default()); options.insertStyleElement = (insertStyleElement_default()); var update = injectStylesIntoStyleTag_default()(PopNotify/* default */.Z, options); /* harmony default export */ const css_PopNotify = (PopNotify/* default */.Z && PopNotify/* default.locals */.Z.locals ? PopNotify/* default.locals */.Z.locals : undefined); ;// CONCATENATED MODULE: ./src/js/PopNotify.js /** * PopNotify.js * @author CKylinMC * @version 1.1 * @licence MIT */ function popNotifyUnit(title, content, onclick, timeout, style, autoshow) { this.constructor = function (title, content, onclick, timeout) { this.title = title; this.content = content; this.onclick = onclick instanceof Function ? onclick : this.close(this); this.timeout = timeout || 5000; this.id = "PNU_" + Math.floor(Math.random() * 1000000) + new Date().getMilliseconds().toString(); this.posRight = 20; this.posTop = popNotify.getNextYPos(); this.timer = null; this.style = style; this.showing = false; this.destoried = false; // window[this.id] = this; if (autoshow) this.show(); }; this.setPosRight = function (x) { // if (!this.showing) return; x = parseFloat(x); if (isNaN(x)) return; this.posRight = x; this.update(); }; this.setPosTop = function (y) { // if (!this.showing) return; y = parseFloat(y); if (isNaN(y)) return; this.posTop = y; this.update(); }; this.update = function () { let el = document.querySelector("#" + this.id); if (!el) return; el.style.top = this.posTop + "px"; el.style.right = this.posRight + "px"; }; this.clicked = function (e, ev) { return function () { if (e.onclick(ev, e) !== false) e.destory(); }; }; this.show = function () { if (this.timer) clearTimeout(this.timer); let el = document.querySelector("#" + this.id); if (el) el.remove(); el = document.createElement("div"); el.id = this.id; el.className = "popNotifyUnitFrame" + (this.style ? " popStyle-" + this.style : ""); el.onclick = this.clicked(this); el.style.top = this.posTop + "px"; el.style.right = this.posRight + "px"; if (this.title != null) { let t = document.createElement("div"); t.innerText = this.title; t.className = "popNotifyUnitTitle"; t.style.animation = "pntextin .8s forwards .2s cubic-bezier(0, 0.6, 0, 1)"; el.appendChild(t); } if (this.content != null) { let c = document.createElement("div"); c.innerText = this.content; c.className = "popNotifyUnitContent"; c.style.animation = "pntextin .8s forwards .3s cubic-bezier(0, 0.6, 0, 1)"; el.appendChild(c); } let b = document.createElement("i"); b.className = "popNotifyUnitBar"; b.style.animationDuration = this.timeout / 1000 + "s"; el.appendChild(b); this.timer = setTimeout(this.close(this), this.timeout); document.body.appendChild(el); this.showing = true; }; this.close = function (e) { return function () { e.destory(); }; }; this.destory = function (force) { if (this.destoried) return; this.destoried = true; this.showing = false; if (this.timer) clearTimeout(this.timer); let el = document.querySelector("#" + this.id); if (el) { if (force) return el.remove(); el.style.animation = "none"; el.style.animation = "pnout forwards .3s ease-in-out"; setTimeout(this.remove(this), 310); popNotify.refresh(); } popNotify.cleanUp(this); }; this.remove = function (e) { return function () { let el = document.querySelector("#" + e.id); if (el) el.remove(); }; }; this.el = function () { return document.querySelector("#" + this.id); }; this.constructor(title, content, onclick, timeout); } var popNotify = { queue: [], closingAll: false, show: function () { let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; let content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; let style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ""; let timeout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 5; let onclick = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; this.notify(title, content, timeout * 1000, onclick, style); }, success: function () { let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; let content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; let timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5; let onclick = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; this.show(title, content, "success", timeout, onclick); }, info: function () { let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; let content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; let timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5; let onclick = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; this.show(title, content, "info", timeout, onclick); }, warn: function () { let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; let content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; let timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5; let onclick = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; this.show(title, content, "warn", timeout, onclick); }, error: function () { let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; let content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; let timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5; let onclick = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; this.show(title, content, "error", timeout, onclick); }, notify: function (title, content, timeout, onclick, style) { let n = new popNotifyUnit(title, content, onclick, timeout, style, true); this.queue.push(n); this.refresh(); return n; }, cleanUp: function (obj) { if (this.closingAll) return; if (obj) this.queue.forEach((item, index) => { if (item === obj) this.queue.splice(index, 1); });else for (let i = 0; i < this.queue.length; i++) { if (this.queue[i].showing === false) { this.queue.splice(i, 1); i -= 1; } } }, refresh: function () { let top = 20; let height = top; this.queue.forEach(item => { if (!item.showing) return; item.setPosTop(height); height += top + item.el().offsetHeight; }); }, getNextYPos: function () { let top = 20; let height = top; this.queue.forEach(item => { if (!item.showing) return; height += top + item.el().offsetHeight; }); return height; }, getObjById: function (id) { if (!id) return; let res = null; this.queue.forEach(item => { if (item.id === id) res = item; }); return res; }, getObjByElement: function (e) { if (!e) return; if (!e instanceof HTMLElement) return; let id = null; if (e.classList.contains("popNotifyUnitFrame")) { id = e.id; } else if (e.classList.contains("popNotifyUnitTitle") || e.classList.contains("popNotifyUnitContent")) { id = e.parentNode.id; } let res = null; this.queue.forEach(item => { if (item.id === id) res = item; }); return res; }, close: function (item) { let obj; if (item instanceof HTMLElement) { obj = this.getObjByElement(item); } else { obj = this.getObjById(item); } if (!obj) return; obj.destory(); }, closeAll: function () { this.closingAll = true; this.queue.forEach(item => item.destory()); this.queue = []; this.closingAll = false; } }; /* harmony default export */ const js_PopNotify = (popNotify); // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./src/style/css/upload-doms.css var css_upload_doms = __webpack_require__("./node_modules/css-loader/dist/cjs.js!./src/style/css/upload-doms.css"); ;// CONCATENATED MODULE: ./src/style/css/upload-doms.css var upload_doms_options = {}; upload_doms_options.styleTagTransform = (styleTagTransform_default()); upload_doms_options.setAttributes = (setAttributesWithoutAttributes_default()); upload_doms_options.insert = insertBySelector_default().bind(null, "head"); upload_doms_options.domAPI = (styleDomAPI_default()); upload_doms_options.insertStyleElement = (insertStyleElement_default()); var upload_doms_update = injectStylesIntoStyleTag_default()(css_upload_doms/* default */.Z, upload_doms_options); /* harmony default export */ const style_css_upload_doms = (css_upload_doms/* default */.Z && css_upload_doms/* default.locals */.Z.locals ? css_upload_doms/* default.locals */.Z.locals : undefined); ;// CONCATENATED MODULE: ./src/functions/file-upload/file-uploader.js function fileUploader() { if ($("span:contains('查看作业任务')").length == 0) { // 判断是否在作业页面 return; } $('.infotable>tbody>tr:contains("请输入你的答案")').after(upload_doms.box); $('#filenames, #buttonDiv, #fileInfo').hide(); // 全局变量 let onUpload = 0; let index = 0; let isAbort = 0; let alreadyLoaded = 0; let startTime = 0; let flag = 0; let filelist = []; // 信息显示部分 let upldIconList = ['🕒', '⚡', '✅', '🕒', '⌛', '🔒', '✅']; // 所有icon统一管理 let fileTypeIconList = ['📄', '⛺', '📚', '🎬', '📝', '📜', '🎵']; // 动效 $('#inputDiv').mouseenter(function () { $('#inputDiv').css({ 'background-color': '#aad63d' }); $('#textShow').css('color', '#ffffff'); }); $('#inputDiv').mouseleave(function () { $('#inputDiv').css({ 'background-color': '#c6f062' }); $('#textShow').css('color', '#424d55'); }); function appendObjects(filelist) { // 缓存区更新前DOM操作 $('#filenames, #buttonDiv, #fileInfo').show(); $('#filenames, #buttonDiv').empty(); // 清空缓存区 $('#inputDiv').hide(); // 隐藏上传框 let sizeType = getSizeType(filelist); let nameType = getNameType(filelist); let fileType = getFileType(filelist); for (let i = 0; i < filelist.length; i++) { let item = {}; item.file = filelist[i]; item.sizeType = sizeType[i]; item.initName = item.file.name; item.showName = nameType[i]; item.fileTypeIcon = fileType[i].icon; item.fileTypeInfo = fileType[i].info; let fileObject = /*html*/ `
    ${item.fileTypeIcon}  |  ${item.showName} (${item.sizeType.size}${item.sizeType.type})
    `; $('#filenames').append(fileObject); } // 缓存区更新后DOM操作 $('#buttonDiv').append(upload_doms.uploadBtn); $('#buttonDiv').append(upload_doms.emptyBtn); // 动效 (所有Object都已插入完毕) $('.fileObjects').mouseenter(function () { // 1.文字加粗 2.展示全名 let prevName = $(this).find('.filename').html(); $(this).find('.filename').css('font-weight', 'bold'); $('.fileObjects').mouseleave(function () { $(this).find('.filename').css('font-weight', ''); $(this).find('.filename').html(prevName); }); if (onUpload == 1 && index == $(this).attr('id').split('fileTh')[1]) { // 文件已经开始上传且this为正在上传的文件, 此后的命令将不被执行 return; } $(this).find('.filename').html($(this).find('.filename').attr('title')); }); $('.fileindex').mouseenter(function () { if (onUpload == 1 || $(this).attr('title') == '[已上传]') { // 上传进程已开始/已经上传完 屏蔽按钮 return; } let iconNow = $(this).html(); let titleNow = $(this).attr('title'); $(this).html('❌'); $(this).attr('title', '删除'); $('.fileindex').mouseleave(function () { if (onUpload == 1 || $(this).attr('title') == '[已上传]') { return; } $(this).html(iconNow); $(this).attr('title', titleNow); }); }); } // 文件选择前事件监听 $('#inputDiv').click(() => { $('#currentFile').trigger('click'); }); $('#currentFile').change(function () { flag = 0; filelist = []; // 先执行清空 再push fileChangedByInput(); }); function fileChangedByInput() { if (flag == 0) { let filelistTMP = {}; for (let i = 0; i < $('#currentFile')[0].files.length; i++) { filelistTMP = $('#currentFile')[0].files[i]; filelist.push(filelistTMP); filelistTMP = {}; } } // 缓存区更新 appendObjects(filelist); // 文件更新后事件监听 $('#emptyTrigger').click(function () { $('#currentFile').val(''); $('#filenames, #buttonDiv').empty(); $('#inputDiv').show(); isAbort = 1; onUpload = 0; filelist = []; $('#filenames, #buttonDiv, #fileInfo').hide(); }); $('.fileindex').click(function () { if (onUpload == 1 || $(this).attr('title') == '[已上传]') { // 上传进程已开始/已经上传完 屏蔽按钮 return; } let th = $(this).attr('id').split('fileindex')[1]; filelist.splice(th, 1); // 缓存区更新 appendObjects(filelist); flag = 1; // 执行change前,flag置1,不重新读文件 fileChangedByInput(); flag = 0; // 执行change后,flag置0,为下次重新读文件做准备 if (filelist.length == 0) { // 点击的文件是最后一个文件,则直接执行清空 $('#emptyTrigger').trigger('click'); } }); // 上传按钮的监听要放在change中: change后才有#uploadtrigger $('#uploadTrigger').click(function () { $('#uploadTrigger').hide(); if (onUpload == 1) { // 上传进程开始,屏蔽按钮 return; } // 处理文件缓存区 isAbort = 0; // 按上传之前按过清空,将isAbort置回0 sendFileMsg(); function sendFileMsg() { if (index >= filelist.length) { // 递归结束 $('#currentFile').val(''); // 文件清空 index = 0; // 递归条件置零 onUpload = 0; // 上传开始标志位置0 return; // 结束递归 } let formData = new FormData(); formData.append('Filename', filelist[index].name); formData.append('Filedata', filelist[index]); let xReq = new XMLHttpRequest(); xReq.open('POST', 'http://cc.bjtu.edu.cn:81/meol/servlet/SerUpload'); xReq.addEventListener("load", onSuccess); xReq.addEventListener("error", onError); xReq.upload.onloadstart = onStart; xReq.upload.onprogress = onProgress; xReq.upload.onabort = onAbort; xReq.send(formData); function onStart() { onUpload = 1; // 上传标志位置1 startTime = new Date().getTime(); // 设置上传开始时间,用以计算时间速度 alreadyLoaded = 0; // 设置上传开始时,已上传的文件大小为0 // 上传开始,缓存区加入竖线 // $('#speedTh'+index).prepend('  |  '); if (filelist[index].size > 52428800) { // 大于50M文件 插入timeremain竖线 $('#timeRemainTh' + index).before('  |  '); } } function onProgress(evt) { if (isAbort == 1) { xReq.abort(); // 上传过程中随时检查,终止请求 } // 进度计算 let percentage = (evt.loaded * 100 / evt.total).toFixed(0); // 速度计算 let nt = new Date().getTime(); // 获取当前时间 let perTime = (nt - startTime) / 1000; // 计算出上次调用该方法时到现在的时间差,单位为s startTime = new Date().getTime(); //重新赋值,用以下次计算 let perLoad = evt.loaded - alreadyLoaded; // 计算该分段上传的文件大小,单位b alreadyLoaded = evt.loaded; // 重新赋值,用以下次计算 let speed = perLoad / perTime; // 单位 B/s let bspeed = speed; let Sunits = 'B/s'; if (speed / 1024 > 1) { speed = speed / 1024; Sunits = 'KB/s'; } if (speed / 1024 > 1) { speed = speed / 1024; Sunits = 'MB/s'; } speed = speed.toFixed(1); // 时间计算 文件>20MB触发 if (evt.total > 20971520) { let restTime = ((evt.total - evt.loaded) / bspeed).toFixed(0); // 实时更新文件缓存区 $('#timeRemainTh' + index).html(upldIconList[0] + restTime + 's'); $('#timeRemainTh' + index).attr('title', '剩余时间'); } // 实时更新文件缓存区 $('#fileTh' + index).css('background-size', percentage + '%'); $('#speedTh' + index).html('  |  ' + upldIconList[1] + speed + Sunits); } function onAbort() { isAbort = 0; // 终止条件置零 index = 0; // 请求终止后index也必须归零,准备发起第二次上传请求 onUpload = 0; // 上传标志位置0 } function onSuccess() { // 插入编辑器操作 let myiframe = document.getElementsByTagName('iframe')[1].contentDocument; let textArea = myiframe.getElementsByClassName('cke_show_borders'); let constructor = '

    ' + filelist[index].name + '

    '; if ($(textArea).find("p>br").length >= 1) { $(textArea).find("p")[0].remove(); } $(textArea).append(constructor); // 处理缓存区操作 let clipboard = new ClipboardJS('#filenameTH' + index); // 要用id做索引 否则会重复调用.on let fileURL = 'http://cc.bjtu.edu.cn:81/meol/' + this.responseText; $('#filenameTH' + index).attr("data-clipboard-text", fileURL); $('#filenameTH' + index).css('cursor', 'pointer'); $('#fileindex' + index).html('' + upldIconList[2] + ''); $('#fileindex' + index).attr('title', '[已上传]'); $('#speedTh' + index).html(''); $('#timeRemainTh' + index).remove(); $('#fileTh' + index).css('background', '#ffffff'); $('#fileTh' + index).css('font-color', '#e7e8e0'); clipboard.on('success', function (evt) { js_PopNotify.show("成功", `【${$(evt.trigger).text()}】 文件链接已复制到剪切板`, "success"); evt.clearSelection(); }); // 递归操作 index++; sendFileMsg(); } function onError() { alert('Failed'); } } }); } // 拖拽上传功能 let oBox = document.getElementById('inputDiv'); let timer = null; document.ondragover = function () { clearTimeout(timer); timer = setTimeout(function () { // 文件放下后执行操作 $('#p1').html('📁文件上传📝'); $('#inputDiv').css('background-color', '#c6f062'); $('#textShow').css('color', '#424d55'); }, 200); }; // 进入子集的时候 会触发ondragover 频繁触发 不给ondrop机会 oBox.ondragover = function () { return false; }; oBox.ondragleave = function () { $('#p1').html('📌请将文件拖拽到此区域'); $('#inputDiv').css('background-color', '#aad63d'); $('#textShow').css('color', '#ffffff'); }; oBox.ondrop = function (ev) { $('#currentFile')[0].files = ev.dataTransfer.files; fileChangedByInput(); return false; }; function getSizeType(filelist) { let RtnsizeType = []; for (let item of filelist) { let sizeTypeTMP = {}; if (item.size < 1024) { sizeTypeTMP.size = item.size.toFixed(2); sizeTypeTMP.type = 'B'; } else if (item.size > 1024 && item.size < 1048576) { sizeTypeTMP.size = (item.size / 1024).toFixed(2); sizeTypeTMP.type = 'KB'; } else if (item.size > 1048576 && item.size < 1073741824) { sizeTypeTMP.size = (item.size / 1048576).toFixed(2); sizeTypeTMP.type = 'MB'; } else if (item.size > 1073741824) { js_PopNotify.show("警告", "你选择了大于1GB的文件,服务器存储资源有限,建议选择其他传输方式。", "warn"); sizeTypeTMP.size = (item.size / 1073741824).toFixed(2); sizeTypeTMP.type = 'GB'; } RtnsizeType.push(sizeTypeTMP); } return RtnsizeType; } function getNameType(filelist) { // 文件名显示长度限制 let nameType = []; let limit; for (let item of filelist) { let splitName = item.name.split('.'); // 预防文件名中含.的情况 let newName = splitName[0]; for (let i = 1; i < splitName.length - 1; i++) { newName = newName + '.' + splitName[i]; } limit = isChina(newName); // 即时生成limit限制 if (newName.length > limit) { // 有后缀超长文件 newName = newName.slice(0, limit) + '... .' + splitName.pop(); } else if (newName.length == 0) { // 无后缀文件 newName = splitName[0]; } else { // 默认去掉了后缀 把后缀加回来 newName = newName + '.' + splitName.pop(); } nameType.push(newName); } function isChina(str) { if (escape(str).indexOf("%u") < 0) { return 35; // 不包含中文 } else { return 20; // 包含中文 } } return nameType; } function getFileType(filelist) { // 文件图标类型 let fileType = []; for (let item of filelist) { let fileTypeTMP = {}; if (item.type.indexOf('image') != -1) { fileTypeTMP.icon = fileTypeIconList[1]; fileTypeTMP.info = '[图像]'; } else if (item.type.indexOf('zip') != -1) { fileTypeTMP.icon = fileTypeIconList[2]; fileTypeTMP.info = '[压缩文件]'; } else if (item.type.indexOf('video') != -1) { fileTypeTMP.icon = fileTypeIconList[3]; fileTypeTMP.info = '[视频]'; } else if (item.type.indexOf('officedocument') != -1 || item.type.indexOf('excel') != -1 || item.type.indexOf('word') != -1 || item.type.indexOf('powerpoint') != -1) { fileTypeTMP.icon = fileTypeIconList[4]; fileTypeTMP.info = '[文档]'; } else if (item.type.indexOf('pdf') != -1) { fileTypeTMP.icon = fileTypeIconList[5]; fileTypeTMP.info = '[文档]'; } else if (item.type.indexOf('audio') != -1) { fileTypeTMP.icon = fileTypeIconList[6]; fileTypeTMP.info = '[音频]'; } else { fileTypeTMP.icon = fileTypeIconList[0]; fileTypeTMP.info = '[文件]'; } fileType.push(fileTypeTMP); } return fileType; } } /* harmony default export */ const file_uploader = (fileUploader); ;// CONCATENATED MODULE: ./src/functions/common/send-request.js async function sendRequest(url, callBack, options) { let res = await fetch(url, options).then(response => { return response.blob(); }).then(blob => { return new Promise(resolve => { let reader = new FileReader(); reader.onload = () => { let htmlData = reader.result; htmlData = new window.DOMParser().parseFromString(htmlData, "text/html"); resolve(htmlData); }; reader.readAsText(blob, 'GBK'); }); }).then(response => { return callBack(response); }).catch(error => { console.error(error); }); return res; } /* harmony default export */ const send_request = (sendRequest); ;// CONCATENATED MODULE: ./src/functions/send-request/get-info.js const baseUrl = `http://cc.bjtu.edu.cn:81/meol`; const userinfoUrl = `${baseUrl}/welcomepage/student/index.jsp`; // 个人信息leftBar const reminderUrl = `${baseUrl}/welcomepage/student/interaction_reminder.jsp`; // 互动提醒reminder const lessonUrl = `${baseUrl}/lesson/blen.student.lesson.list.jsp`; // 课程列表courselist const hwtListUrl = `${baseUrl}/common/hw/student/hwtask.jsp`; // 课程作业hwtlist async function getUserInfo() { let stuInfo = await send_request(userinfoUrl, obj => { return obj.querySelectorAll(".userinfobody>ul>li"); }).then(res => { let obj = { name: '', loginTime: '', onlineTime: '', loginTimes: '' }; res.forEach((item, index) => { obj[Object.keys(obj)[index]] = item.innerText.split(":")[1].trim(); }); return obj; }).catch(error => { console.log(error); }); return stuInfo; } async function getRemindInfo() { let remindInfo = await send_request(reminderUrl, obj => { return obj.querySelectorAll("ul[id='reminder']>li>ul"); }).then(res => { let obj = { notify: [], hwt: [] }; res.forEach((it, ind) => { it.querySelectorAll("li>a").forEach(item => { let classobj = { name: '', id: '', type: '' }; classobj.name = item.innerText.trim(); classobj.id = item.getAttribute("href").split("lid=")[1].split("&t=")[0]; classobj.type = item.getAttribute("href").split("lid=")[1].split("&t=")[1]; if (classobj.type === "hw") { obj["hwt"].push(classobj); } else if (classobj.type === "info") { obj["notify"].push(classobj); } }); }); return obj; }).catch(error => { console.log(error); }); return remindInfo; } async function getLessonInfo() { let lessonInfo = await send_request(lessonUrl, obj => { return obj.querySelectorAll("tbody>tr"); }).then(res => { let arry = []; res.forEach((item, index) => { if (index === 0) return; let obj = { id: '', name: '', academy: '', teacher: '' }; obj.id = item.firstElementChild.firstElementChild.getAttribute("href").split("lid=")[1]; obj.name = item.firstElementChild.firstElementChild.innerText.split("\n")[0].trim(); obj.academy = item.children[1].innerText.split("\n")[0]; obj.teacher = item.children[2].innerText.split("\n")[0]; arry.push(obj); }); return arry; }).catch(error => { console.log(error); }); return lessonInfo; } async function getHwtInfo() { let hwtInfo = await send_request(hwtListUrl, obj => { return obj.querySelectorAll("tbody>tr"); }).then(res => { let arry = []; res.forEach((item, index) => { if (index === 0) return; let obj = { hwtID: '', hwtName: '', date: '', DateObj: '', remainTime: '', able: false }; obj.hwtID = item.querySelectorAll(".infolist")[0].getAttribute("href").split("hwtid=")[1]; obj.hwtName = item.querySelectorAll(".infolist")[0].innerText.split("\n")[0].trim(); obj.date = item.children[1].innerText.split("\n")[0]; obj.DateObj = new Date(`${obj.date.split("年")[0]},${obj.date.split("年")[1].split("月")[0]},${obj.date.split("年")[1].split("月")[1].split("日")[0]},23:59:59`); obj.remainTime = parseInt((obj.DateObj.valueOf() - new Date().valueOf()) / (24 * 60 * 60 * 1000)); obj.able = item.children[5].childElementCount !== 0; arry.push(obj); }); return arry; }).catch(error => { console.log(error); }); return hwtInfo; } /* harmony default export */ const get_info = ({ getUserInfo: getUserInfo, getRemindInfo: getRemindInfo, getLessonInfo: getLessonInfo, getHwtInfo: getHwtInfo }); ;// CONCATENATED MODULE: ./src/functions/get-homework-more-info.js const get_homework_more_info_baseUrl = `http://cc.bjtu.edu.cn:81/meol`; const courseUrl = `${get_homework_more_info_baseUrl}/jpk/course/layout/newpage/index.jsp?courseId=`; const taskanswerUrl = `${get_homework_more_info_baseUrl}/common/hw/student/taskanswer.jsp?hwtid=`; // 查看批阅结果taskanswer.jsp const writeUrl = `${get_homework_more_info_baseUrl}/common/hw/student/write.jsp?hwtid=`; // 查看作业任务write.jsp const onceSubmitInfo = "该作业不允许重复提交,确定提交作业吗?"; const hadSubmitTag = /*html*/ ` 🟢 `; const notSubmitTag = /*html*/ ` 🟠 `; const onceSubmitTag = /*html*/ ` 🔒 `; const freeSubmitTag = /*html*/ ` 🔄 `; async function initializate(courseID) { let inPage = false; if (location.href.indexOf("hwtask.jsp") === -1) { inPage = false; } else { inPage = true; } if (inPage) { // dont initializate, get info directly let a = await appendSubmitInfo(); let b = await appendOnceInfo(); js_PopNotify.show(`成功`, "已加载作业信息", "success", 2.5); } else { // initializate, dont get info if (courseID === undefined) return; let init = await send_request(courseUrl + courseID, obj => { return obj; // nothing todo }).catch(error => { console.log(error); }); return init; } } async function appendSubmitInfo() { let hwtList = await get_info.getHwtInfo(); for (let it of hwtList) { // cant await in forEach // if (it.able == false) return let append = await send_request(taskanswerUrl + it.hwtID, obj => { return $(obj).find("tr:contains('回答的内容')+tr>td>input").length; }).then(res => { if (res === 1) { $(document.querySelectorAll(".infolist[href='hwtask.view.jsp?hwtid=" + it.hwtID + "']")[0]).before(hadSubmitTag); } else { $(document.querySelectorAll(".infolist[href='hwtask.view.jsp?hwtid=" + it.hwtID + "']")[0]).before(notSubmitTag); } }).catch(error => { console.log(error); }); // return append } } async function appendOnceInfo() { let hwtList = await get_info.getHwtInfo(); for (let it of hwtList) { // cant await in forEach if (it.able == false) return; let append = await send_request(writeUrl + it.hwtID, obj => { return obj.querySelectorAll("script"); }).then(res => { if (res[7].innerText.indexOf(onceSubmitInfo) !== -1) { $(document.querySelectorAll(".infolist[href='hwtask.view.jsp?hwtid=" + it.hwtID + "']")[0]).before(onceSubmitTag); } else { $(document.querySelectorAll(".infolist[href='hwtask.view.jsp?hwtid=" + it.hwtID + "']")[0]).before(freeSubmitTag); } }).catch(error => { console.log(error); }); // return append } } /* harmony default export */ const get_homework_more_info = (initializate); // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js!./src/style/css/reminderCSS.css var reminderCSS = __webpack_require__("./node_modules/css-loader/dist/cjs.js!./src/style/css/reminderCSS.css"); ;// CONCATENATED MODULE: ./src/style/css/reminderCSS.css var reminderCSS_options = {}; reminderCSS_options.styleTagTransform = (styleTagTransform_default()); reminderCSS_options.setAttributes = (setAttributesWithoutAttributes_default()); reminderCSS_options.insert = insertBySelector_default().bind(null, "head"); reminderCSS_options.domAPI = (styleDomAPI_default()); reminderCSS_options.insertStyleElement = (insertStyleElement_default()); var reminderCSS_update = injectStylesIntoStyleTag_default()(reminderCSS/* default */.Z, reminderCSS_options); /* harmony default export */ const css_reminderCSS = (reminderCSS/* default */.Z && reminderCSS/* default.locals */.Z.locals ? reminderCSS/* default.locals */.Z.locals : undefined); ;// CONCATENATED MODULE: ./src/functions/get-reminder.js const get_reminder_baseUrl = `http://cc.bjtu.edu.cn:81/meol`; const hwtUrl = `${get_reminder_baseUrl}/common/hw/student/write.jsp?hwtid=`; const hwtTagTemplate = /*html*/ ``; function sortByTime() { let liList = $(".listwrap>.list>ul>li"); let remainList = []; for (let i = 0; i < liList.length; i++) { remainList.push($(liList[i]).find(".date").attr("remain")); } remainList.sort((a, b) => { return a - b; }); remainList.forEach((it, ind) => { for (let i = 0; i < liList.length; i++) { if ($(liList[i]).find(".date").attr("remain") === it) { $(".listwrap>.list>ul").append(liList[i]); } } }); } async function createHwtList(remindInfo) { $(".list>ul").empty(); for (let courseItem of remindInfo.hwt) { // Async Trap: cannot async in forEach await get_homework_more_info(courseItem.id).then(async () => { await get_info.getHwtInfo().then(hwtList => { let ableHwtList = hwtList.filter(hwtItem => { return hwtItem.able == true && hwtItem.remainTime <= 15; }); for (let hwtItem of ableHwtList) { let hwtTag = document.createElement("li"); hwtTag.innerHTML = hwtTagTemplate; let Info = ``; if (hwtItem.remainTime === 0) { Info = `今日截止`; } else { Info = `[还有${hwtItem.remainTime}天截止]`; } $(hwtTag).find(".hwtName").text(`${Info} ${hwtItem.hwtName} [${courseItem.name}]`); $(hwtTag).find(".date").text(hwtItem.DateObj.toLocaleDateString()); $(hwtTag).find(".date").attr("remain", `${hwtItem.remainTime}`); if (hwtItem.remainTime <= 3) { $(hwtTag).find("a").addClass("top"); } $(hwtTag).click(() => { get_homework_more_info(courseItem.id).then(() => { window.open(`${hwtUrl}${hwtItem.hwtID}`, "_parent"); }); }); $(".list>ul").append(hwtTag); } }); }); } } async function drawRed(remindInfo) { remindInfo.hwt.forEach(courseItem => { $(".courseList").find("a[href*='" + courseItem.id + "']").css("color", "#C00"); }); } async function getReminderNew() { if (location.href.indexOf('welcomepage/student/index.jsp') == -1) return; let remindInfo = await get_info.getRemindInfo().then(res => { createHwtList(res).then(() => { js_PopNotify.show("成功", "作业列表加载完毕", "success", 2.5); sortByTime(); }); drawRed(res); }); } /* harmony default export */ const get_reminder = (getReminderNew); ;// CONCATENATED MODULE: ./src/functions/get-resources.js function getResources() { if (location.href.indexOf('listview.jsp?') == -1) { return; } let fileLinks = []; for (let i = 0; i < $('tbody>tr').length; i++) { let href = $($('tbody>tr')[i]).find('td>a').attr('href'); if (href && href.indexOf('listview.jsp?') != 0) { fileLinks.push('http://cc.bjtu.edu.cn:81/meol/common/script/download.jsp' + $($('tbody>tr')[i]).find('td>a').attr('href').split('download_preview.jsp')[1]); } } $('.subtitle').append( /*html*/ `下载此目录下所有文件`); $('#downloadAll').click(() => { if (fileLinks.length) { fileLinks.forEach(value => { window.open(value); }); } else js_PopNotify.show("警告", "当前目录下无文件", "warn"); }); } /* harmony default export */ const get_resources = (getResources); ;// CONCATENATED MODULE: ./src/functions/only-once-commit.js function judgeOnceSubmit() { if (location.href.indexOf("write.jsp") === -1) return; if ($("script:contains('该作业不允许重复提交,确定提交作业吗?')").length != 0) { let newspan = '(只能提交一次)'; $('span:contains("查看作业任务")').after(newspan); js_PopNotify.show("警告", "注意,此作业只能提交一次,请检查无误后再提交!", "warn"); return 1; } else return 0; } /* harmony default export */ const only_once_commit = (judgeOnceSubmit); ;// CONCATENATED MODULE: ./src/functions/check-update.js const { version } = __webpack_require__("./package.json"); async function getLastestVersion() { const GreasyUrl = "https://greasyfork.org/zh-CN/scripts/432056"; let res = send_request(GreasyUrl, obj => { return obj.querySelectorAll('.script-show-version>span')[1].textContent; }); return res; } async function checkVersion() { if (location.href.indexOf('welcomepage/student/index.jsp') == -1) { // 只发welcome页的一次请求 return; } getLastestVersion().then(res => { let weightLastest = 0; let weightNow = 0; res.split('.').reverse().forEach((value, index) => { weightLastest += (index + 1) * value; }); version.split('.').reverse().forEach((value, index) => { weightNow += (index + 1) * value; }); if (weightLastest > weightNow) { console.log('need update'); js_PopNotify.show(`有新版本[${res}]`, "点击安装新版本", "success", "90", () => { window.open(`https://greasyfork.org/zh-CN/scripts/432056`); }); } else console.log('version Checked'); }); } /* harmony default export */ const check_update = (checkVersion); ;// CONCATENATED MODULE: ./src/index.js append_tags(); file_uploader(); get_reminder(); get_resources(); get_homework_more_info(); only_once_commit(); check_update(); })(); /******/ })() ;