// ==UserScript== // @name 阿里云盘脚本V5.2【去他妈的最终版理论停止更新】 // @namespace http://bbs.tampermonkey.net.cn/ // @version 66.78 // @description 【bbs.tampermonkey.net.cn】李恒道 // @author 【bbs.tampermonkey.net.cn】李恒道 // @match https://passport.aliyundrive.com/* // @match https://www.aliyundrive.com/drive/* // @match https://www.aliyundrive.com/drive // @match https://aliyundrive.com/drive/* // @match https://aliyundrive.com/drive // @match http://passport.aliyundrive.com/* // @match http://www.aliyundrive.com/drive/* // @match http://www.aliyundrive.com/drive // @match http://aliyundrive.com/drive/* // @match http://aliyundrive.com/drive // @icon https://www.google.com/s2/favicons?domain=aliyundrive.com // @require https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.js // @require https://cdn.bootcdn.net/ajax/libs/js-sha1/0.6.0/sha1.js // @grant unsafeWindow // @grant GM_setClipboard // @grant GM_xmlhttpRequest // @connect aliyundrive.com // @connect alicloudccp.com // @run-at document-start // ==/UserScript== let username='' let password='' //自动登陆配置项 let NewLink=true; //使用新版链接 let FileList=[] let Searchlist=[] let CreateListner=false; let GenerateFileInShow=false; let parent_file_id='root' let listurl='' let CreateSaveBtn=false; let Totallistnum=0; let Sublistnum=0; var ShowFileObj={ name:'文件获取失败', content_hash:'hash获取失败', size:'公众号:叛逆青年旅舍,来自油猴中文网:bbs.tampermonkey.net.cn', content_type:'Fucccccck', file_id:'天才少年李恒道', content_type:'系统李恒道吹牛逼理论,QQ4548212' } let accesstoken='' let filenum=0; let next_markerlist=[] let totalnum=0; let Uploadlist=[] let Success=0; let Faile=0; let GenerateDialogShow;//对话框1 let GenerateFileinDialogShow;//对话框2 let GenerateShow=false let uploadsize=1000000 //他妈看不懂了,写的是啥 function GetFileSha1Encr(tempobj){ if(NewLink==true) { let name=tempobj.name.replace('|','=') if(name==='') { name='nameisnull' } return 'aliyunpan://'+name+'|'+tempobj.content_hash.replace('|','=')+'|'+tempobj.size+'|'+tempobj.content_type.replace('|','=') } return window.btoa(unescape(encodeURIComponent(JSON.stringify({ name:tempobj.name, content_hash:tempobj.content_hash, size:tempobj.size, content_type:tempobj.content_type, })))) } function CurrentText() { var d = new Date(), str = ''; str += d.getFullYear() + '年'; str += d.getMonth() + 1 + '月'; str += d.getDate() + '日'; str += d.getHours() + '时'; str += d.getMinutes() + '分'; str += d.getSeconds() + '秒'; return str+'序列文件.txt'; } async function CreateTextUpload(name,size,hash){ return new Promise((resolve, reject) => { let useruid=JSON.parse(localStorage.getItem('token')).default_drive_id let uploadtext='{"drive_id":"'+useruid+'","part_info_list":[{"part_number":1}],"parent_file_id":"'+parent_file_id+'","name":"'+name+ '","type":"file","check_name_mode":"auto_rename","size":'+size+',"content_hash":"'+hash+'","content_hash_name":"sha1"}' GM_xmlhttpRequest({ url:"https://api.aliyundrive.com/v2/file/create", method :"POST", data:uploadtext, headers: { "Content-type": "application/json;charset=utf-8", "Authorization": accesstoken }, onload:function(xhr){ resolve(xhr.responseText); } }); }); } async function UploadTextBin(tageturl,targetdata){ return new Promise((resolve, reject) => { GM_xmlhttpRequest({ url:tageturl, method :"PUT", data:targetdata, headers: { "Content-type": " ", "Referer": "https://www.aliyundrive.com/", // "Authorization": accesstoken }, //binary:true, onload:function(xhr){ resolve(xhr.responseText); } }); }); } async function Complete(upload_id,file_id){ return new Promise((resolve, reject) => { let useruid=JSON.parse(localStorage.getItem('token')).default_drive_id let uploadtext='{"drive_id":"'+useruid+'","upload_id":"'+upload_id+'","file_id":"'+file_id+'"}' GM_xmlhttpRequest({ url:'https://api.aliyundrive.com/v2/file/complete', method :"POST", data:uploadtext, headers: { "Content-type": "application/json;charset=utf-8", "Authorization": accesstoken }, onload:function(xhr){ resolve(xhr.responseText); } }); }); } async function UploadTextToAliYunpan(text){ var tempblob=new Blob([text]) if(tempblob.size>uploadsize) { alert('文件超出脚本限制大小,无法上传至云盘!请选择导出文件') return; } let create=JSON.parse(await CreateTextUpload(CurrentText(),tempblob.size,sha1(text))) if(create.rapid_upload==true){ alert('网盘内存在该文件!') } let createurl=create.part_info_list[0].upload_url await UploadTextBin(createurl,text) let finishret= await Complete(create.upload_id,create.file_id) if(finishret.indexOf('file_id')==-1) { alert('保存至网盘失败!') } finishret=JSON.parse(finishret) let sharurl=GetFileSha1Encr(finishret) alert('保存至网盘成功!,已设置到剪辑版') GM_setClipboard(sharurl) //file_id JSON.parse console.log('UploadTextToAliYunpan',finishret) } function GetDecrText(text){ debugger; if(text.indexOf('115://')!==-1) { let sizelist=text.replace('115://','').split('|') if(sizelist.length<4) { return 'Error' } if(sizelist.length>4) { var n = parseInt(sizelist[1]); if (!isNaN(n)) { return {content_hash:sizelist[2],content_type:'null',name:sizelist[0],size:sizelist[1]} } let temp=text let sizelength=text.replace('115://','').split('|').length-4 for(let num=0;num
文件批量导入(请勿导入时关闭)
多文件批量导出 公众号:叛逆青年旅舍
作者天才少年李恒道QQ4548212
油猴中文网bbs.tampermonkey.net.cn
开始提取
导入文件
当前已选:0
` GenerateFileinDialogShow.onclick=function(event){ //多选关闭删除 if(event.target.outerHTML.indexOf('#PDSClose')!=-1) { Uploadlist=[] GenerateFileInShow=false; GenerateFileinDialogShow.remove() return; } if(event.target.outerHTML.indexOf('导入文件')!=-1) { document.getElementById("uploadfile").click(); return; } if(event.target.outerHTML.indexOf('开始提取')!=-1) { alert('正在开始上传,请勿重复点击!') StartAllFile() return; } } document.querySelector('body').append(GenerateFileinDialogShow) } function MulFileDialogCreate(){ if(GenerateFileInShow==true) { Uploadlist=[] GenerateFileInShow=false; GenerateFileinDialogShow.remove() } if(GenerateShow==true) { return; } GenerateShow=true GenerateDialogShow=document.createElement('div') GenerateDialogShow.innerHTML=`
文件批量导出
多文件批量导出 公众号:叛逆青年旅舍
作者天才少年李恒道QQ4548212
油猴中文网bbs.tampermonkey.net.cn
搜索文件
搜索
保存至网盘
导出
全部选择
当前共:330
` GenerateDialogShow.onclick=function(event){ debugger; console.log('去他妈的导出',event.target) //多选关闭删除 if(event.target.outerHTML.indexOf('#PDSClose')!=-1) { GenerateShow=false; GenerateDialogShow.remove() return; } if(event.target.innerText=='全部选择') { document.querySelectorAll('.FileListOutShow >div').forEach(item=>{ SetSelectItem(item,true) }) return; } if(event.target.innerText=='搜索') { SearchFileMulInsert(document.querySelector('[name="SearchMulFile"]').value); return; } if(event.target.innerText=='保存至网盘') { let outtext='阿里云油猴插件By:油猴中文版\n作者:天才少年李恒道QQ:4548212\n公众号:叛逆青年旅舍\n油猴中文网:bbs.tampermonkey.net.cn\n' document.querySelectorAll('.FileListOutShow >div').forEach(item=>{ if(item.checkbox==true){ outtext=outtext+item.name+'\n'+item.date+'\n' } }) if(outtext!=='阿里云油猴插件By:油猴中文版\n作者:天才少年李恒道QQ:4548212\n公众号:叛逆青年旅舍\n油猴中文网:bbs.tampermonkey.net.cn\n') { alert('开始进行上传,请勿重复点击!') UploadTextToAliYunpan(outtext) } else{ alert('未选择任何文件') } return; } if(event.target.innerText=='导出') { let outtext='阿里云油猴插件By:油猴中文版\n作者:天才少年李恒道QQ:4548212\n公众号:叛逆青年旅舍\n油猴中文网:bbs.tampermonkey.net.cn\n' document.querySelectorAll('.FileListOutShow >div').forEach(item=>{ if(item.checkbox==true){ outtext=outtext+item.name+'\n'+item.date+'\n' } }) if(outtext!=='阿里云油猴插件By:油猴中文版\n作者:天才少年李恒道QQ:4548212\n公众号:叛逆青年旅舍\n油猴中文网:bbs.tampermonkey.net.cn\n') { download('导出文件成功By:油猴中文网.txt',outtext) } else{ alert('未选择任何文件') } return; } } document.querySelector('body').append(GenerateDialogShow) SearchFileMulInsert('') } function LoadDownloadText(url){ debugger; GM_xmlhttpRequest({ url:url, method :"GET", headers: { //"Content-type": "application/json;charset=utf-8", "Referer": "https://www.aliyundrive.com/", // "Authorization": accesstoken }, onload:function(xhr){ debugger; MulReadialogCreate() AddText(xhr.responseText) alert('解析完成!') console.log('解析文本内容!',xhr.responseText) } }); } function DownloadTextRead(obj){ alert('开始读取文件内容,时长根据网速决定,请勿重复点击'); console.log('获取远程对象开始',obj) let useruid=JSON.parse(localStorage.getItem('token')).default_drive_id let uploadtext='{"drive_id":"'+useruid+'","file_id":"'+obj.file_id+'"}' GM_xmlhttpRequest({ url:"https://api.aliyundrive.com/v2/file/get_download_url", method :"POST", data:uploadtext, headers: { "Content-type": "application/json;charset=utf-8", "Referer": "https://www.aliyundrive.com/", "Authorization": accesstoken }, onload:function(xhr){ var json = JSON.parse(xhr.responseText); if(json.url===undefined) { alert('获取下载地址失败!') return; } LoadDownloadText(json.url) } }); //MulReadialogCreate() } async function UploadOne(num){ return new Promise((resolve, reject) => { let obj=Uploadlist[num] let text=GetDecrText(obj.date) let useruid=JSON.parse(localStorage.getItem('token')).default_drive_id let uploadtext='{"drive_id":"'+useruid+'","part_info_list":[{"part_number":1}],"parent_file_id":"'+parent_file_id+'","name":"'+text.name+'","type":"file","check_name_mode":"auto_rename","size":'+text.size+',"content_hash":"'+text.content_hash+'","content_hash_name":"sha1"}' GM_xmlhttpRequest({ url:"https://api.aliyundrive.com/v2/file/create", method :"POST", data:uploadtext, headers: { "Content-type": "application/json;charset=utf-8", "Authorization": accesstoken }, onload:function(xhr){ var json = JSON.parse(xhr.responseText); if(json.rapid_upload==true) { Success++; SetSelectItem(obj,true,false) resolve('success'); } else{ Faile++; SetSelectItem(obj,false,false) resolve('faile'); } } }); }); } async function StartAllFile(){ Uploadlist=document.querySelectorAll('.FileListOutShow >div') Success=0; Faile=0; for(let index=0;index
'+temp.size+'
' document.querySelector('.FileListOutShow').append(FileItem) } } } if(document.querySelectorAll('.FileListOutShow >div').length==0) { alert('找不到分享码!') } } function ReadFileList(evt){ totalnum=0 SetTotalnum() let files = evt.files if (files.length > 0) { let file = files[0]; let reader = new FileReader(); reader.readAsText(file); reader.onloadend = () => { let result = reader.result; AddText(result) }; } } function download(filename, text) { var element = document.createElement('a'); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); element.setAttribute('download', filename); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element); } function uploadadded(event){ } function SetTotalnum(){ document.querySelector('.SelectNumShow span').innerText=totalnum } function SetSelectItem(item,check,change=true){ if(item.checkbox===check) { return; } if( item.checkbox===false) { item.checkbox=true if(change==true) { totalnum+=1 SetTotalnum() } item.children[0].children[2].setAttribute('data-checked','true') item.children[0].children[2].innerHTML='
' } else{ item.checkbox=false if(change==true) { totalnum-=1 SetTotalnum() } item.children[0].children[2].setAttribute('data-checked','false') item.children[0].children[2].innerHTML='
' } } function SearchFileMulInsert(text){ document.querySelector('.FileListOutShow').innerText='' totalnum=0 for(let index=0;index
'+tempobj.size+'
' FileItem.onclick=function(event){ if(event.target.outerHTML.indexOf('checkbox')!==-1||event.target.outerHTML.indexOf('M12.6247 5.29974L7.26637')!==-1) { SetSelectItem(FileItem,!FileItem.checkbox) } } document.querySelector('.FileListOutShow').append(FileItem) } } } } SetTotalnum() } function ShowToast(text,time=3000){ let toast=document.createElement('div') toast.innerHTML='
' + text+ '
' document.querySelector('body').append(toast) setInterval(function(){toast.remove() }, time); } function RefreshToken(){ if(accesstoken!=='') { return; } GM_xmlhttpRequest({ url:"https://websv.aliyundrive.com/token/refresh", method :"POST", data:'{"refresh_token": "'+JSON.parse(localStorage.getItem('token')).refresh_token+'"}', headers: { "Content-type": "application/json;charset=utf-8", }, onload:function(xhr){ var json = JSON.parse(xhr.responseText); accesstoken=json.access_token if(accesstoken!==undefined&&accesstoken!='') { } else{ ShowToast('解析Acess_Token失败!') } } }); } function CreateShareClip(tempobj){ ShowFileObj.name=tempobj.name; ShowFileObj.content_hash=tempobj.content_hash; ShowFileObj.size=tempobj.size; ShowFileObj.content_type=tempobj.content_type; ShowFileObj.file_id=tempobj.file_id; let ret=confirm('文件名:'+ShowFileObj.name+'\n校验值:'+ShowFileObj.content_hash+'\n文件大小:'+ShowFileObj.size+'\n'+ '点击确定自动添加分享码到剪辑版\n来自油猴中文网bbs.tampermonkey.net.cn\n公众号:叛逆青年旅舍'); if(ret==true) { try { GM_setClipboard(GetFileSha1Encr(tempobj)) alert('文件已设置到剪辑版!') } catch(err) { alert('文件名字可能存在特殊关键字,请改名重试') } } } function StartListner(){ setInterval(function(event) { if(CreateSaveBtn===false) { let header=document.querySelector('[class|=header]') if(header!==null&&header.childElementCount===2&&document.querySelector('[class|=header]').children[1].innerText.indexOf('提取分享码')===-1){ let GenerateShareBtn=document.createElement('div') GenerateShareBtn.innerHTML='
提取分享码
' GenerateShareBtn.onclick=function(){ var text=prompt("请输入分享码",""); if(text==null) { return;} try{ text=GetDecrText(text) }catch(err){ alert('解析提取码失败!') return; } if(text.content_hash==undefined) { alert('提取码不正确!') } else{ if(accesstoken=='') { alert('访问Token异常!') return; } let useruid=JSON.parse(localStorage.getItem('token')).default_drive_id let uploadtext='{"drive_id":"'+useruid+'","part_info_list":[{"part_number":1}],"parent_file_id":"'+parent_file_id+'","name":"'+text.name+'","type":"file","check_name_mode":"auto_rename","size":'+text.size+',"content_hash":"'+text.content_hash+'","content_hash_name":"sha1"}' GM_xmlhttpRequest({ url:"https://api.aliyundrive.com/v2/file/create", method :"POST", data:uploadtext, headers: { "Content-type": "application/json;charset=utf-8", "Authorization": accesstoken }, onload:function(xhr){ var json = JSON.parse(xhr.responseText); if(json.rapid_upload==true) { alert("提取文件成功!") unsafeWindow.location.reload(); } else{ alert("提取文件失败!") } } }); } } let GenerateFileOut=document.createElement('div') GenerateFileOut.innerHTML='
多文件分享
' GenerateFileOut.onclick=function(){ MulFileDialogCreate() } let GenerateFileIn=document.createElement('div') GenerateFileIn.innerHTML='
多文件提取
' GenerateFileIn.onclick=function(){ MulReadialogCreate() } document.querySelector('[class|=header]').children[1].append(GenerateShareBtn) document.querySelector('[class|=header]').children[1].append(GenerateFileOut) document.querySelector('[class|=header]').children[1].append(GenerateFileIn) } } //info-wrapper-- let formlist=document.querySelectorAll('.ant-modal-body') for(let forminedx=0;forminedxuploadsize){ alert('该文本文档的大小过大!无法使用该功能') } else{ let temlist=document.querySelectorAll('[role="document"] [data-icon-type="PDSClose"]') for(let index=0;index{ if(item.innerText.indexOf('移动')!==-1) { if(item.offsetWidth!==0) { quit=true } } }) if(quit) { return; } let item=JSON.parse(xhr.response) if(listurl===unsafeWindow.location.href) { if(xhr.CreatFirstList==true) { FileList=[{name:item.next_marker,list:item.items}] filenum=item.items.length } else{ let Search=false; FileList.forEach((item)=>{ if(item.name===item.next_marker) { item.list=item.items Search=true } }) if(Search===false&&xhr.NextList==true) { FileList.push({name:item.next_marker,list:item.items}) filenum+=item.items.length } } } else{ listurl=unsafeWindow.location.href FileList=[{name:item.next_marker,list:item.items}] filenum=item.items.length } if(CreateListner===false) { StartListner() CreateListner=true } RefreshToken() ShowToast('已获取文件列表 数量为'+filenum+'(数字如不准请联系作者) By:天才少年李恒道') } } }); }); } if(unsafeWindow.location.href.indexOf('passport.aliyundrive.com/mini_login.htm')!=-1) { let container=document.querySelector('#container'); container.addEventListener("DOMNodeInserted", function(event) { if(username=='') { return} if(password=='') { return} let header=document.querySelector('.login-blocks') if(header===null) { return; } document.querySelector('.login-blocks').children[1].click() document.querySelector('#fm-login-id').value=username document.querySelector('#fm-login-password').value=password document.querySelector('.password-login').click() }); return; }