Greasy Fork

Greasy Fork is available in English.

Mepgk Downloader|环保清单批量下载器

默认自动下载,并默认下载位置

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Mepgk Downloader|环保清单批量下载器
// @namespace    //https://tankywoo.com
// @version      0.0.1 
// @description  默认自动下载,并默认下载位置
// @author       修改//Tanky Woo
// @include      http*://*/*
// @require      https://cdn.bootcss.com/jquery/3.2.1/jquery.js
// @grant        GM_addStyle
// @run-at       document-idle
// @license      MIT License
// ==/UserScript==
/*global $, confirm, console, GM_addStyle*/
(function() {
  'use strict';
  // 说明:

  var downloader_style = [
    '.picture-downloader {',
    'position: fixed;',
    'right: 0; bottom: 0;',
    'border: 1px solid gray;',
    'z-index:999}'
  ];
  GM_addStyle(downloader_style.join(' '));
  var btn = [
    '<div class="picture-downloader">',
    '<button type="button" class="picture-downloader-btn5">批量下载国五DOC</button>',
    '<button type="button" class="picture-downloader-btn6">批量下载国六DOC</button>',
    '</div>'
  ];
  $('body').prepend(btn.join('\n'));
    //国五批量下载
  $('.picture-downloader-btn5').on('click', function() {
    var match_url = '/file/download/xxgkh?';
    var images = $("a.icon-download[title='下载清单模版']").map(function() {
      var img_src = $(this).attr('href');
      if (img_src.indexOf(match_url) !== -1) {
        console.log(img_src);
        return img_src;
      }
    }).get();

    // show all images
      var i=0;
    $(images).each(function() {
      console.log(this);
        i++;
    });

    var ans = confirm('将要下载以下国五DOC['+i+']个:\n' + images.join('\n'));

    if (ans) {
      $(images).each(function() {
        var a = $('<a>')
          .attr('href', this)
          .attr('download', '')
          .appendTo('body');
        a[0].click();
          sleep(500);
      });
    }
  });
  //国六批量下载
  $('.picture-downloader-btn').on('click', function() {
    var match_url = '/file/download/xxgkh?';
    var images = $("a.icon-download[title='下载清单模版反面']").map(function() {
      var img_src = $(this).attr('href');
      if (img_src.indexOf(match_url) !== -1) {
        console.log(img_src);
        return img_src;
      }
    }).get();

    // show all images
    var i=0;
    $(images).each(function() {
      console.log(this);
        i++;
    });

    var ans = confirm('将要下载以下国六DOC['+i+']个:\n' + images.join('\n'));

    if (ans) {
      $(images).each(function() {
        var a = $('<a>')
          .attr('href', this)
          .attr('download', '')
          .appendTo('body');
        a[0].click();
          sleep(500);
      });
    }
  });

    function sleep(d){
        for(var t = Date.now();Date.now() - t <= d;);
    }
})();