Greasy Fork

Greasy Fork is available in English.

office 365 cloud disc batch download / office 365 云盘批量下载

office 365 云盘批量下载自带的批量下载大于60G以上文件总是失败

当前为 2021-09-04 提交的版本,查看 最新版本

// ==UserScript==
// @name        office 365 cloud disc batch download / office 365 云盘批量下载
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  office 365 云盘批量下载自带的批量下载大于60G以上文件总是失败
// @author       friday_club
// @match        https://*.sharepoint.com/*
// @icon         https://www.google.com/s2/favicons?domain=sharepoint.com
// @grant       GM_notification
// @grant       GM_cookie
// @grant       GM.setValue
// @grant       GM.getValue
// ==/UserScript==

(function() {
    'use strict';
    window.onload= ()=>{
        console.log("~~~~~~~~~ 365 cloud disc batch download run")
        const interval = 300;
        const sleep = (time = 1000) => new Promise((resolve) => setTimeout(resolve, time));
        const oneByOneRun = (list, project, wait = 1000) => {
            list.reduce((future, e, idx, arr) => {
                return future.then((unCheck) => {
                    return new Promise(async (resolve) => {
                        await project(e, idx, arr);
                        setTimeout(resolve, wait)
                    })
                })
            }, Promise.resolve())
        };
        const createBtn = ()=>{
             var btn=document.createElement("BUTTON");
            var t=document.createTextNode("一键全部下载");
            btn.appendChild(t);
            document.getElementsByClassName("ms-OverflowSet ms-CommandBar-primaryCommand")[0].appendChild(btn)
            return btn
        }
        const btn = createBtn()
        btn.addEventListener('click',async ()=>{
            const checkList = Array.from(document.getElementsByClassName("ms-SelectionZone")[0].firstElementChild.children)
            .map(v=>{return v.firstElementChild.firstElementChild.firstElementChild.firstElementChild.firstElementChild});

            const downloadBtn = document.getElementsByClassName("ms-Button ms-Button--commandBar ms-CommandBarItem-link")[0].firstChild;
            oneByOneRun(checkList,async (checkbox ) => {
                checkbox.click();
                await sleep(interval);
                downloadBtn.click();
                await sleep(interval);
                checkbox.click();
            },interval);
        })
    }
})();