// ==UserScript== // @name 【bbs.tampermonkey.net.cn】阿里云盘脚本V2.1 // @namespace http://bbs.tampermonkey.net.cn/ // @version 2.1 // @description try to take over the world! // @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 // @icon https://www.google.com/s2/favicons?domain=aliyundrive.com // @require https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.js // @grant unsafeWindow // @grant GM_setClipboard // @grant GM_xmlhttpRequest // @connect aliyundrive.com // ==/UserScript== let username='' let password='' //自动登陆配置项 let FileList=[] let CreateListner=false; 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=[] 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(window.btoa(unescape(encodeURIComponent(JSON.stringify({ name:tempobj.name, content_hash:tempobj.content_hash, size:tempobj.size, content_type:tempobj.content_type, }))))) 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("请输入分享码",""); text=decodeURIComponent(escape(window.atob(text))) text=JSON.parse(text) if(text.content_hash==undefined) { alert('提取码不正确!') } else{ let useruid=JSON.parse(localStorage.getItem('token')).default_drive_id let uploadtext='{"drive_id":"'+useruid+'","part_info_list":[{"part_number":1}],"parent_file_id":"root","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("提取文件失败!") } } }); } } document.querySelector('[class|=header]').children[1].append(GenerateShareBtn) } } //info-wrapper-- let form=document.querySelector('.ant-modal-body') if(form!=null&&form.innerHTML.indexOf('详细信息')!=-1) { if(form.innerHTML.indexOf('创建时间')!=-1) { let img=document.querySelector('.ant-modal-body img') if(img!==null&&img.alt==="folder") { if(document.querySelector('.ant-modal-body').innerText.indexOf('生成分享')!==-1) { document.querySelector('.ant-modal-body [data-type="primary"]').remove() } return; } if(form.innerHTML.indexOf('生成分享')==-1) { let GenerateFileDate=document.createElement('div') GenerateFileDate.innerHTML='
生成分享
' GenerateFileDate.onclick=function(){ let name=document.querySelector('[class|=title-wrapper]').innerText 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) { console.log('xhr',xhr) 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) { FileList.push({name:item.next_marker,list:item.items}) console.log('filenum3',filenum,item.items.length) filenum+=item.items.length } } } else{ listurl=unsafeWindow.location.href FileList=[{name:item.next_marker,list:item.items}] filenum=item.items.length } console.log('FileList',FileList) 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; }