免登录直接下载天翼云盘分享链接的方法

前几天天翼云送出大量会员,体验了下,上传下载都很不错,唯一不方便就是下载被分享的文件必须登录,今天看到了一个可以免登录下载方法。

1.首先添加一个书签,内容是下面部分的代码:


javascript:(function(){'use strict';function sleep(ms){return new Promise(resolve=>setTimeout(resolve,ms))};async function main(ms){while(true){if(document.cookie.indexOf("COOKIE_LOGIN_USE")!=-1){break;};let title=document.getElementsByClassName("title")[0].innerText;let saveAs=document.getElementsByClassName("btn btn-save-as")[0].innerText;if(title!="属于私密分享,请输入访问码后查看"){console.log(title);if(saveAs=="转存当前目录"){let cookie_name="shareId_"+_shareId;let passcode=get_code(cookie_name);get_download_url(passcode);break;}else if(saveAs=="转存到云盘"){document.getElementsByClassName("btn btn-download")[0].target="_blank";document.getElementsByClassName("btn btn-download")[0].href=downloadUrl;document.getElementsByClassName("btn btn-download")[0].className="btn btn-download download";break;};};await sleep(ms);}};function get_code(cookie_name){let ck=document.cookie.split(';');for(let i=0;i<ck.length;i++){let cookie=ck[i].trim();if(cookie.indexOf(cookie_name)==0){return cookie.split('=')[1];}}};function get_download_url(passcode){let urlArray=new Array();let url="https://cloud.189.cn/v2/listShareDir.action?shareId="+_shareId+"&accessCode="+passcode+"&verifyCode="+_verifyCode+"&orderBy=1&order=ASC&pageNum=1&pageSize=60";fetch(url,{method:"GET"}).then(response=>response.json()).then(data=>{for(let i in data.data){let download_url="https:"+data.data[i].downloadUrl;console.log(download_url);document.getElementsByClassName("file-icon")[i].onclick=function(){window.open(download_url);};urlArray[i]=download_url;};return urlArray;});};main(1000);})();

 

2.每次打开分享链接后,就打开一次这个书签,就能实现免登录下载。

 

 

原文链接:https://www.hostloc.com/thread-678677-1-1.html

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注