webdav

坚果云

La data de 02-04-2023. Vezi ultima versiune.

Acest script nu ar trebui instalat direct. Aceasta este o bibliotecă pentru alte scripturi care este inclusă prin directiva meta a // @require https://update.greasyfork.org/scripts/463081/1169718/webdav.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

class webdav{constructor(a,b){this.Account=a,this.Password=b}NewFolder(a){let b={authorization:`Basic ${btoa(this.Account+":"+this.Password)}`};return new Promise((c,d)=>{GM_xmlhttpRequest({method:"MKCOL",timeout:3e3,headers:b,url:`https://dav.jianguoyun.com/dav/${a}/`,onload:c,onerror:d,ontimeout:d})})}UploadFiles(a,b,c,d){let e={authorization:`Basic ${btoa(this.Account+":"+this.Password)}`};return new Promise((f,g)=>{GM_xmlhttpRequest({method:"PUT",timeout:3e3,data:c,headers:e,url:`https://dav.jianguoyun.com/dav/${a}/${b}`,dataType:d,onload:function(a){201==a.status||204==a.status?f(!0):(console.error(a),f(!1))},onerror:g,ontimeout:g})})}DownloadFile(a,b){let c={authorization:`Basic ${btoa(this.Account+":"+this.Password)}`};return new Promise((d,e)=>{GM_xmlhttpRequest({method:"GET",timeout:3e3,headers:c,url:`https://dav.jianguoyun.com/dav/${a}/${b}`,onload:function(a){200==a.status?d(a.responseText):(console.error(a),d(!1))},onerror:e,ontimeout:e})})}GetAllFile(a,b){return new Promise((c,d)=>{GM_xmlhttpRequest({method:"PROPFIND",url:"https://dav.jianguoyun.com/dav/"+a,headers:{Authorization:`Basic ${btoa(this.Account+":"+this.Password)}`,Depth:b},onload:function(a){if(207==a.status){for(var b=new DOMParser,e=b.parseFromString(a.responseText,"text/xml"),f=e.getElementsByTagNameNS("DAV:","response"),g=[],h=0;h<f.length;h++){var j=f[h].getElementsByTagNameNS("DAV:","href")[0].textContent,k=f[h].getElementsByTagNameNS("DAV:","propstat")[0],l=k.getElementsByTagNameNS("DAV:","status")[0].textContent;if(l.includes("200 OK")){var m=k.getElementsByTagNameNS("DAV:","resourcetype")[0];0<m.getElementsByTagNameNS("DAV:","collection").length&&(j+="/"),g.push(j)}}c(g)}else console.error(a),d(new Error("The request failed with status code "+a.status))}})})}ExistsFile(a){return new Promise((b,c)=>{console.log(this),GM_xmlhttpRequest({method:"HEAD",url:"https://dav.jianguoyun.com/dav/"+a,headers:{Authorization:`Basic ${btoa(this.Account+":"+this.Password)}`},onload:function(a){var d=a.status;200==d?b(!0):404==d?b(!1):403==d?(b(!1),c("\u6743\u9650\u4E0D\u8DB3,\u62D2\u7EDD\u8BBF\u95EE")):c("The status code is "+d+" and the status text is "+a.statusText)}})})}}function AutoUploadFiles(a,b,c,d,e){return e||(e={},GM_listValues().forEach(function(a){e[a]=GM_getValue(a)})),new Promise(f=>{console.log("\u4E0A\u4F20\u6570\u636E",e);let g=GM_getValue("LBackupTimestamp",0),h=Date.now();if(86400000<h-g){let g=new webdav(a,b);g.ExistsFile(c).then(async a=>{a||(await g.NewFolder(c)),f(await g.UploadFiles(c,d,e,"json")),GM_setValue("LBackupTimestamp",h)})}else console.log("\u5907\u4EFD\u95F4\u9694\u9700\u8981\u5927\u4E8E24\u5C0F\u65F6")})}