// ==UserScript==
// @name minerva-online assistant
// @namespace https://space.bilibili.com/17846288
// @version 2.5.9
// @license MIT
// @description 此脚本能更方便使用minerva-online平台,可在顶端菜单栏右下角的按钮处设置功能开关,并查看功能详情
// @author inoki
// @include https://www.minerva-online.com/*
// @require https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_xmlhttpRequest
// @connect fanyi.baidu.com
// @noframes
// @downloadURL none
// ==/UserScript==
/*jshint esversion: 9*/
(()=>{
'use strict';
const $=window.$;
const SET=[
{
'id':0,
'name':'置顶置底',
'func':()=>{GOTOPBOTTOM();},
'unfunc':()=>{unGOTOPBOTTOM();},
'detail':
`在平台域名所有可滚动页面生效,页面右下方添加置顶置底按钮
按钮会根据页面滚动方向自动切换置顶和置底,按钮样式可在代码中自定义中修改`,
'switch':1
},
{
'id':1,
'name':'菜单遮罩',
'func':()=>{COVERMENU();},
'unfunc':()=>{unCOVERMENU();},
'detail':
`在有顶端菜单栏的页面生效
让菜单栏需要点击一次后才可展开,防止鼠标经过时误触 (默认关闭)`,
'switch':0
},
{
'id':2,
'name':'附件下载',
'func':()=>{DOWNLOADFILE();},
'unfunc':()=>{unDOWNLOADFILE();},
'detail':
`在问卷管理页面生效,每份报告前添加↓按钮
点击↓加载附件列表,点击√下载全部附件,点击附件名下载单个附件,鼠标悬停可预览图片`,
'switch':1
},
{
'id':3,
'name':'扣分标记',
'func':()=>{MARKQUESTION();},
'unfunc':()=>{unMARKQUESTION();},
'detail':
`在单店报告页面生效
将题目中勾选扣分和n/a项标色,选项更改后需保存报告才会刷新标记,方便快速检查相关题评论
可在简介上方设置扣分(默认为红)和N/A(默认为绿)的标记颜色,点击√保存更改,保存后关开此功能可在报告页面即时刷新颜色`,
'switch':1
},
{
'id':4,
'name':'评论编辑',
'func':()=>{COMMENTEDIT();},
'unfunc':()=>{unCOMMENTEDIT();},
'detail':
`在单店报告页面生效,右下方按钮展开操作界面
使用前请注意阅读操作界面最上方的【点击获取提示】
输入匹配内容(支持正则)会即时显示匹配的评论框数量并标灰,点击一键替换可批量修改所有评论框内容
点击首字母大写可智能将所有句首字母变为大写,并标灰发生过修改的评论框,只对英文生效
点击评论翻译会调用百度翻译,在每个评论框下方输出目标语言翻译,点击↑可将下方内容添加至评论框`,
'switch':1
},
{
'id':5,
'name':'验证输出',
'func':()=>{VERIFYEXPORT();},
'unfunc':()=>{unVERIFYEXPORT();},
'detail':
`在问卷管理页面生效,表头上方添加按钮
点击按钮弹出确认提示,确认后会验证输出当前页面勾选的所有报告,成功后会在每份报告下方小窗口显示绿色保存成功提示
(电脑配置较低时一次输出太多份可能导致页面卡死,请根据浏览器最多同时能开几个报告页面量力而行,默认关闭)`,
'switch':0
},
{
'id':6,
'name':'定制汇总',
'func':()=>{CUSTOMROLLUP();},
'unfunc':()=>{unCUSTOMROLLUP();},
'detail':
`在定制汇总页面生效,在汇总表格上方添加“复制表格”按钮
点击按钮可一键复制表格全部内容,方便复制到excel等软件中编辑`,
'switch':1
},
];
/*在顶端菜单栏添加MOassist设置按钮*/
const menu=$('div#menu');
if(menu.length){
menu.find('ul.tools').append(`
......');
$.get(`
/open/data.asp?post={
"action":"exec",
"dataset":{"datasetname":"/Apps/SM/Survey/SurveyInstanceGetData"},
"parameters":[{"name":"SurveyInstanceID","value":"${surveyid}"}]
}`,(data,status)=>{//调用API获取当前survey数据[SurveyInstanceGetData]
if (status==='success'){
try{
data.dataset.data[3];
}catch(e){
$('p#'+surveyid+'.loading').after('登录失效!');
DownloadButton0(surveyid);
}
const filedata=data.dataset.data[3];
const fileno=filedata.length;
$('p#'+surveyid+'.loading').after('\t#='+fileno+'');
if (fileno>0){
for(let i in filedata){
const filename=filedata[i].FileName+'.'+filedata[i].FileExtension;
const fileid=filedata[i].AttachmentID;
const fileurl='/mystservices/Attachments/getAttachment.asp?Attachment='+fileid+'&Password='+filedata[i].Password+'';
let filesize=Number(filedata[i].FileSizeInBytes)/1024;
filesize= (filesize>1024)? (filesize/1024).toFixed(2)+' MB' : filesize.toFixed(2)+' KB';
$('
').appendTo('ol#'+surveyid+'.filelist');
$(` '+filesize+' ').appendTo('tr#'+fileid);
}
$('a#'+surveyid+'.I,a#'+surveyid+'.V').mouseenter(function(){
FilePreview(1,$(this).attr('href'));
}).mouseleave(()=>{
FilePreview(0);
});
$('ol#'+surveyid+'.filelist').prepend('');
$('button#'+surveyid+'.yes').on('click',()=>{
DownloadAll(surveyid);
});
}
}else{
$('p#'+surveyid+'.loading').after('网络错误!');
}
DownloadButton0(surveyid);
},"json");
}
//预览附件图片
function FilePreview(show,src){
if(show){
const imgid=src.split('=')[2];
if($('img#'+imgid+'.filepreview').length===0){
$('').appendTo('body');
$('img#'+imgid+'.filepreview').attr('src',src+'&getThumbnail=1').css('height','200px')//视频附件预览图&getThumbnail=1
.parent().css({'position':'fixed','zIndex':10000,'height':'200px','background':'url(/images/icons/filtersv2/loading06.gif)'});
}
$('img#'+imgid+'.filepreview').parent().css({'top':event.clientY-200+'px','left':event.clientX+100+'px'});
$('img#'+imgid+'.filepreview').show();
}else{
$('img.filepreview').hide();
}
}
//按钮变为关闭
function DownloadButton0(surveyid){
$('p#'+surveyid+'.loading').remove();
$('button#'+surveyid+'.download').one('click',()=>{
DownloadButton1(surveyid);
});
$('button#'+surveyid+'.download').text('×');
$('button#'+surveyid+'.download').show();
}
//按钮重置为初始
function DownloadButton1(surveyid){
$('ol,b').remove('#'+surveyid);
$('button#'+surveyid+'.download').one('click',()=>{
DownloadButton(surveyid);
});
$('button#'+surveyid+'.download').text('↓');
}
//下载全部
function DownloadAll(surveyid){
$('button#'+surveyid+'.yes').hide();
const iframe=$('ol#'+surveyid+'.filelist').find('iframe');
if(iframe.length)iframe.remove();
setTimeout(()=>{
$('button#'+surveyid+'.yes').show();
},1000*$('ol#'+surveyid+'.filelist').find('a').length);//有几个附件就隐藏按钮几秒
$('ol#'+surveyid+'.filelist').find('a').each(function(){
$('