Greasy Fork

Greasy Fork is available in English.

minerva-online下载报告附件

在问卷管理页面生效,点击↓加载附件列表,点击附件名下载单个附件,点击√下载全部附件

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         minerva-online下载报告附件
// @namespace    http://greasyfork.icu/scripts/431414-minerva-online%E4%B8%8B%E8%BD%BD%E6%8A%A5%E5%91%8A%E9%99%84%E4%BB%B6
// @version      0.2
// @description  在问卷管理页面生效,点击↓加载附件列表,点击附件名下载单个附件,点击√下载全部附件
// @author       inoki
// @match        https://www.minerva-online.com/document.asp?alias=smngr.surveyexplorer
// @resource     https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {

    'use strict';


    $("div.sticky-wrap").find(":checkbox").each(function(){//checkbox后添加下载按钮
        var surveyid=$(this).val();
        $(this).after('<button type=button id='+surveyid+' class=download><b>↓');
        $("#"+surveyid+".download").on("click",download_button0);
    });


    //按钮初始功能:获取附件列表
    function download_button0(){
        var surveyid=$(this).attr("id");
        $("#"+surveyid+".download").after('<p id='+surveyid+' class=loading><b>......');
        $.get("/document.asp?alias=survey.view&InstanceID="+surveyid,function(data,status){//获取当前survey内容并获取附件数量、名称、链接
            if (status="success"){
                $("p#"+surveyid+".loading").after('<ol id='+surveyid+' class=attlist>\n#='+$(data).find("td.attachLeftCell").size()+'');
                $(data).find("td.attachLeftCell").each(function(){
                    var fileurl=$(this).find("img.attachedImg").attr("src");
                    if (fileurl.indexOf("Visual.asp?")>=0){
                        fileurl=$(this).find("div.media-player").attr("data-source");
                    }
                    var filename=$(this).next().find("div.propValueContent.propValueFileName").text();
                    if (fileurl.indexOf("getImage")>=0){
                        fileurl=fileurl.replace("Image.asp?","Attachment.asp?Attachment");
                        fileurl=decodeURI(fileurl);
                    }
                    $('<li><a id='+surveyid+' class=file href='+fileurl+'>'+filename+'</li>').appendTo("ol#"+surveyid+".attlist");
                });
                $("p#"+surveyid+".loading").remove();
                $("button#"+surveyid+".download").unbind();
                $("button#"+surveyid+".download").on("click",download_button1);
                $("button#"+surveyid+".download").text("×");
                $("#"+surveyid+".attlist").prepend('<button type=button id='+surveyid+' class=yes><b>√');
                $("button#"+surveyid+".yes").on("click",download_yes);
            }
        });
    };

    //按钮重置为初始
    function download_button1(){
        var surveyid=$(this).attr("id");
        $("ol").remove("#"+surveyid);
        $("button#"+surveyid+".download").unbind();
        $("button#"+surveyid+".download").on("click",download_button0);
        $("button#"+surveyid+".download").text("↓");
    };

    //确认下载
    function download_yes(){
        var surveyid=$(this).attr("id");
        var url=$("a#"+surveyid+".file");
        for(var i=0;i<url.length;i++){
            window.open($(url[i]).attr("href"));
        }
        $("button#"+surveyid+".yes").text("〇");
    };


})();