摘要:百度网盘好友分享时一键转存脚本

var list = document.getElementsByClassName("global-clearfix")[3];

var lioflist = list.getElementsByTagName("li");

var divofli = new Array();

var countone = lioflist.length;

var countback,clickb, clickpath, clickpath, counttwo,d=0;

var control=200;

function dosave() {
 
     counttwo = d + control;
     countback = d;

    
    if (counttwo > countone) {
        counttwo = countone;
    }
    
    console.log("进入保存");
    console.log("进入保存时的countback"+countback);
    console.log("进入保存时的counttwo"+counttwo);
    
    for (var i = countback; i < counttwo; i++) {
        divofli[i].click();
    }
    d = d + control;
   
    
    clickb = document.getElementsByClassName("global-btn global-btn-transfer");
    clickb[1].click();
    clickpath = document.getElementsByClassName("save-chk-io");
    clickpath[0].click();
    clicksub = document.getElementsByClassName("sbtn global-float-right");
    clicksub[0].click();
}

function doback() {
    console.log("进入返回");
    console.log("进入返回时的countback"+countback);
    console.log("进入返回时的counttwo"+counttwo);
   
    for (var i = countback; i < counttwo; i++) {
        divofli[i].click();
    }
}

for (var i = 0; i < countone; i++) {
    divofli.push(lioflist[i].getElementsByClassName("sharelist-item-name")[0]);
}

for (var j = 0; j < countone; j += control) {
   
    setTimeout(dosave, 3000+j/control*120000);
    setTimeout(doback, 120000+j/control*120000);

}

参数说明:control变量控制一次转存的数目。假设有一千个文件文件,脚本会分成1000/control次转存。
(1)control中包含的所有文件数目不能超过五百,否则会报错。
(2)必须手动拉动滚动条使得文件完全加载后才能使用脚本,不然会保存不全。