Greasy Fork

Greasy Fork is available in English.

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

office 365 云盘批量下载自带的批量下载大于60G以上文件总是失败,在右下角新增了全部下载按钮,食用方法,配合下载工具,并且切换为无需弹框确认的模式, todo 选择部分的来重新下载

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        office 365 cloud disc batch download / office 365 云盘批量下载
// @namespace    http://tampermonkey.net/
// @version      0.32
// @description  office 365 云盘批量下载自带的批量下载大于60G以上文件总是失败,在右下角新增了全部下载按钮,食用方法,配合下载工具,并且切换为无需弹框确认的模式, todo 选择部分的来重新下载
// @author       friday_club
// @match        https://*.sharepoint.com/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const interval = 100;
    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(() => {
                return new Promise(async (resolve) => {
                    await project(e, idx, arr);
                    await sleep(wait);
                    resolve();
                })
            })
        }, 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)
        btn.style.cssText = `position: absolute;
    bottom: 30px;
    right: 30px;
    height: 60px;
    border: 1px solid rgb(221, 221, 221);
    z-index: 100000;
    background-color: #0078D4;
    color: white;
    cursor: pointer;`;

         document.body.appendChild(btn)
         document.body.style.cssText = document.body.style.cssText + "position: relative;"
        return btn
    }

    const run= async ()=>{
         console.log(">>>>>>>>>>>> 365 cloud disc batch download run >>>>>>>>>>>> ")
         createBtn().addEventListener('click',async ()=>{
            const checkList = Array.from(document.querySelectorAll(".ms-DetailsRow-cell.ms-DetailsRow-cellCheck"));
             //     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;

             for await (const checkbox of checkList) {
                 checkbox.click();
                await sleep(interval);
                downloadBtn.click();
                await sleep(interval);
                checkbox.click();
                await sleep(interval);
             }
        })
    }

    window.document.addEventListener('DOMContentLoaded', run);

})();