Greasy Fork

Greasy Fork is available in English.

金山文档文件批量下载

用于金山文档文件批量下载

当前为 2021-11-17 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         金山文档文件批量下载
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  用于金山文档文件批量下载
// @author       chic1018
// @match        *://www.kdocs.cn/mine/*
// ==/UserScript==

"use strict";


!function(){
    document.querySelector('.nav-action-folder ul').innerHTML = '<li><span><span class="components-icons-box"><i class="components-icons components-icons-nav-download"></i></span><span>简易批量下载</span></span></li>' + document.querySelector('.nav-action-folder ul').innerHTML
    let totalNum
    !function(){
        let scrollHeight
        const fun = setInterval(function(){
            if (scrollHeight != document.querySelector('.yun-list').scrollHeight){
                scrollHeight = document.querySelector('.yun-list').scrollHeight
                document.querySelector('.yun-list').scrollTo(0,scrollHeight)
            }
            else {
                clearInterval(fun)
                totalNum = parseInt(document.querySelector('.yun-list__item:last-child').outerHTML.slice(12,14))+1
                document.querySelector('.yun-list').scrollTo(0,0)
            }
        },50)
        }()
    setTimeout(function(){
        document.querySelector('.nav-action-folder ul li:nth-child(1)').onclick = function(){
            let count = 0
            const downloadFiles = function(){
                if (count>=totalNum){
                    return
                }
                let elemNumber = document.querySelector('.yun-list__content').children.length - 1
                let i = 0
                let download
                let elem0
                let selected = false
                const loop = function(){
                    if (i>=elemNumber){
                        document.querySelector('.yun-list').scrollBy(0,66*elemNumber)
                        return
                    }
                    if (download){
                        download.click()
                        elem0.click()
                        download = null
                        selected = false
                        i++
                        count++
                    }
                    else {
                        elemNumber = document.querySelector('.yun-list__content').children.length - 1
                        let str0='.yun-list__content div[index="'+count+'"] .yun-list__checkbox';
                        elem0 = document.querySelector(str0)
                        if (elem0 && !selected){
                            elem0.click()
                            selected = true
                        }
                        else if (!elem0){
                            document.querySelector('.yun-list').scrollBy(0,66*elemNumber)
                        }
                        download = document.querySelector('.nav-action-selected li:nth-child(4)')
                    }
                    setTimeout(loop,0)
                }
                loop()
                setTimeout(downloadFiles,2000)
            }
            downloadFiles()
        }
    },0)
}()