minerva-online下载报告附件

在问卷管理页面生效,点击↓加载附件列表,点击√可一键下载全部附件,点击附件名下载单个附件,如弹出窗口被拦截请允许后再进行操作

当前为 2021-08-26 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name minerva-online下载报告附件
  3. // @namespace https://greasyfork.org/scripts/431414-minerva-online%E4%B8%8B%E8%BD%BD%E6%8A%A5%E5%91%8A%E9%99%84%E4%BB%B6
  4. // @version 0.3
  5. // @description 在问卷管理页面生效,点击↓加载附件列表,点击√可一键下载全部附件,点击附件名下载单个附件,如弹出窗口被拦截请允许后再进行操作
  6. // @author inoki
  7. // @match https://www.minerva-online.com/document.asp?alias=smngr.surveyexplorer
  8. // @resource https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.  
  14. 'use strict';
  15.  
  16.  
  17. $("div.sticky-wrap").find(":checkbox").each(function(){//checkbox后添加下载按钮
  18. var surveyid=$(this).val();
  19. $(this).after('<button type=button id='+surveyid+' class=download><b>↓');
  20. $("#"+surveyid+".download").on("click",download_button0);
  21. });
  22.  
  23.  
  24. //按钮初始功能:获取附件列表
  25. function download_button0(){
  26. var surveyid=$(this).attr("id");
  27. $("#"+surveyid+".download").after('<p id='+surveyid+' class=loading><b>......');
  28. $.get("/document.asp?alias=survey.view&InstanceID="+surveyid,function(data,status){//获取当前survey内容并获取附件数量、名称、链接
  29. if (status="success"){
  30. $("p#"+surveyid+".loading").after('<ol id='+surveyid+' class=attlist>\n#='+$(data).find("td.attachLeftCell").size()+'');
  31. $(data).find("td.attachLeftCell").each(function(){
  32. var fileurl=$(this).find("img.attachedImg").attr("src");
  33. if (fileurl.indexOf("Visual.asp?")>=0){
  34. fileurl=$(this).find("div.media-player").attr("data-source");
  35. }
  36. var filename=$(this).next().find("div.propValueContent.propValueFileName").text();
  37. if (fileurl.indexOf("getImage")>=0){
  38. fileurl=fileurl.replace("Image.asp?","Attachment.asp?Attachment");
  39. fileurl=decodeURI(fileurl);
  40. }
  41. $('<li><a id='+surveyid+' class=file href='+fileurl+'>'+filename+'</li>').appendTo("ol#"+surveyid+".attlist");
  42. });
  43. $("p#"+surveyid+".loading").remove();
  44. $("button#"+surveyid+".download").unbind();
  45. $("button#"+surveyid+".download").on("click",download_button1);
  46. $("button#"+surveyid+".download").text("×");
  47. $("#"+surveyid+".attlist").prepend('<button type=button id='+surveyid+' class=yes><b>√');
  48. $("button#"+surveyid+".yes").on("click",download_yes);
  49. }
  50. });
  51. };
  52.  
  53. //按钮重置为初始
  54. function download_button1(){
  55. var surveyid=$(this).attr("id");
  56. $("ol").remove("#"+surveyid);
  57. $("button#"+surveyid+".download").unbind();
  58. $("button#"+surveyid+".download").on("click",download_button0);
  59. $("button#"+surveyid+".download").text("↓");
  60. };
  61.  
  62. //确认下载
  63. function download_yes(){
  64. var surveyid=$(this).attr("id");
  65. var url=$("a#"+surveyid+".file");
  66. for(var i=0;i<url.length;i++){
  67. window.open($(url[i]).attr("href"));
  68. }
  69. $("button#"+surveyid+".yes").text("〇");
  70. };
  71.  
  72.  
  73. })();