// ==UserScript==
// @name minerva-online assistant
// @namespace https://space.bilibili.com/17846288
// @version 2.6.7
// @license MIT
// @description 此脚本能更方便使用minerva-online平台,可在顶端菜单栏右下角的按钮处设置功能开关,并查看功能详情
// @author inoki
// @include https://www.minerva-online.com/*
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_xmlhttpRequest
// @connect fanyi.baidu.com
// @noframes
// @downloadURL none
// ==/UserScript==
/*jshint esversion: 9*/
(()=>{
'use strict';
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项标色,选项更改后需保存报告才会刷新标记
可在上方设置扣分(默认为红)和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
},
{
'id':7,
'name':'报告存档',
'func':()=>{SURVEYAUTOSAVE();},
'unfunc':()=>{unSURVEYAUTOSAVE();},
'detail':
`在单店报告页面生效,右下方【书本图标】按钮展开操作界面,可查看自动/手动存档列表
【存档】点击可进行手动存档,每次对报告内容进行修改时,将在本地进行自动存档
【预览】点击可查看存档内容,并对需要读档写入的题目进行勾选
【读档】点击可将选中的存档全部内容写入到当前报告,或只写入预览界面勾选的题目
【删除】点击可删除选中的存档,自动/手动存档上限各为10个,超出时自动删除此类最早存档
(“评论编辑”功能造成的修改不会触发自动存档,可在修改后点击任意评论框触发自动存档)`,
'switch':1
},
];
//用于打印脚本简介
unsafeWindow.MO_logInfo=()=>{
let info='';
for(let s in SET){
info+=parseInt(s)+1+' '+SET[s].name+':\n';
info+=SET[s].detail.replaceAll(' ','').replaceAll('
','');
info+='\n\n';
}
console.log(info);
};
//如网页无jQuery则引入3.6.0
var $=unsafeWindow.$;
if(!$){
const jq=document.createElement('script');
jq.src='https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js';
document.head.appendChild(jq);
jq.onload=()=>{
$=unsafeWindow.jQuery;
init();
};
}else{
init();
}
/*在顶端菜单栏添加MOassist设置按钮*/
function init(){
console.log('jQuery',$.fn.jquery);
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{
const fd=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(){
$('