// ==UserScript== // @name 🧰蓝墨云工具箱 Mosoteach Toolkit // @namespace http://github.com/ellean/ // @version 1.3.0 // @description 让蓝墨云更加强大、易用!Make Mosoteach more powerfull & user-friendly ! // @author Younntone // @match https://www.mosoteach.cn/web/index.php?c=interaction_quiz&m=person_quiz_result&clazz_course_id=*&order_item=group // @match https://www.mosoteach.cn/web/index.php?c=interaction&m=index&clazz_course_id=* // @match https://www.mosoteach.cn/web/index.php?c=res&m=index&clazz_course_id=* // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; /** * * 通用方法 * 用于截取 url 中所需要的参数 * @param name 参数名 * @param url * */ // 获取 当前页面 const a = $('', { href: window.location.search }); const c = a.prop('search').split('?c=')[1].split('&')[0] // 判断 当前页面 switch (c) { case 'interaction_quiz': /** * *---------------------------------------* * * 为 已结束 的 测试活动 添加直接查看分析的按钮 * * *---------------------------------------* */ // 获取 课程 id let clazzCourseId = getQueryString( 'clazz_course_id', window.location.search, ); // 获取 活动节点集合 let activities = $('.interaction-row'); // 判断 每个活动节点是否为测试 for (let index = 0; index < activities.length; index++) { const activity = activities[index]; const activityType = activity.getAttribute('data-type'); const quizStatus = activity.children[1].children[0].children[0].className; // 如果 是测试并且已经结束 if (activityType === 'QUIZ' && quizStatus === 'interaction-status end') { // 添加 直接打开分析页面的按钮 let urlWithId = activity.getAttribute('data-url'); let id = getQueryString('id', urlWithId); let url = `https://www.mosoteach.cn/web/index.php?c=interaction_quiz&m=person_quiz_result&clazz_course_id=${clazzCourseId}&id=${id}&order_item=group`; let button = document.createElement('div'); button.className = 'interaction-status processing'; button.innerText = '习题分析'; button.addEventListener('click', () => { window.open(url); event.stopPropagation(); }); activity.children[1].children[0].appendChild(button); } } break; case 'interaction': /** * *-------------------------------------* * * 为 测试分析 添加导出全部题目到粘贴板的按钮 * * *-------------------------------------* */ const quizTitle = $('.manager-active-name-length')[0].innerText; const quizCollection = $('.view-quiz-row'); // const quizAnswerCollection var quizList = []; // 获取 所有题目 for (let quizIndex = 0; quizIndex < quizCollection.length; quizIndex++) { const quiz = quizCollection[quizIndex]; const num = quiz.children[0].children[0].children[0].children[0].innerHTML; const question = quiz.children[0].children[0].children[0].children[1].children[2] .children[0].innerText; const optionCount = quiz.children[0].children[0].children[2].childElementCount; let options = []; // 获取 该题所有选项 for (let optionIndex = 0; optionIndex < optionCount; optionIndex++) { const optionMark = quiz.children[0].children[0].children[2].children[optionIndex] .children[0].innerText; const option = quiz.children[0].children[0].children[2].children[optionIndex] .children[2].innerText; options.push(` ${optionMark}. ${option}`); } // 获取 答案 let answer = quiz.children[1].children[0].children[0].children[1].innerText; quizList.push(` ${num}. ${question} ${answer} ${options}`); } // 整理内容 var detail = `题目标题: ${quizTitle} 题目总数: ${quizCollection.length} 题目: ${quizList} `; // 创建 按钮节点 var copyButton = document.createElement('button'); copyButton.innerHTML = '导出该测试'; copyButton.style = ` width: 100px; height: 50px; position: fixed; top: 400px; left: 30px; background-color: #EC6941B0; `; copyButton.addEventListener('click', function () { var oInput = document.createElement('textarea'); oInput.value = detail; document.body.appendChild(oInput); oInput.select(); document.execCommand('Copy'); oInput.className = 'oInput'; oInput.style.display = 'none'; alert('已复制到粘贴板'); }); // 挂载 按钮节点 document.body.appendChild(copyButton); break; case 'res': /** * *-------------------------------------* * * 为 资源 添加是否可拖动进度条开关 * * *-------------------------------------* */ const dragSwitch = $('视频进度可拖拽') $('div[data-mime=video]').attr('data-drag', 'Y') dragSwitch.click(() => { if ($("#dragable").attr('class') == 'icon-circle-blank') { $("#dragable").attr('class', 'icon-ok-circle') $('div[data-mime=video]').attr('data-drag', 'Y') } else { $("#dragable").attr('class', 'icon-circle-blank') $('div[data-mime=video]').attr('data-drag', 'N') } }) $("div[style='display:inline-block;']").after(dragSwitch) /** * *-------------------------------------* * * 点开视频再关闭即可实现看完 * * * mosoteach本身BUG导致不需要此段代码 * * *-------------------------------------* */ // $.ajaxSetup({ // beforeSend: function () { // console.log(arguments[1].data) // let data = arguments[1].data // let encodedData = '' // for (const key in data) { // if (data.hasOwnProperty(key)) { // let value = data[key]; // if (key.includes('watch_to')) { // value = data.duration // } // encodedData = encodedData.concat(`&${key}=${value}`) // } // } // arguments[1].data = encodedData.substring(1, encodedData.length) // }, // processData: false // }); break; default: break; } })();