您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
Henry Toys dav api
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/539094/1605712/dav.js
// ==UserScript== // @name dav // @namespace dav // @version 0.0.1 // @description Henry Toys dav api // @author Henry // @include *.amazon.* // @icon https://www.google.com/s2/favicons?sz=64&domain=amazon.com // @grant unsafeWindow // @grant GM_download // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_xmlhttpRequest // @grant GM_registerMenuCommand // @connect *.amazon.* // @connect *.s3.amazonaws.com // @connect open.feishu.cn // @connect dav.jianguoyun.com // @license CC-BY-4.0 // ==/UserScript== const dav = { get_login_data: function () { // 从sessionStorage获取登录数据 let dav_login_data = sessionStorage.getItem("dav_login_data") // 检查数据是否有效 if (dav_login_data == null || JSON.parse(dav_login_data).username == 'null' || JSON.parse(dav_login_data).password == 'null') { // 移除无效数据 localStorage.removeItem('dav_login_data'); // 创建默认登录数据对象 dav_login_data = { "baseURL": "https://dav.jianguoyun.com/dav/", "username": "[email protected]", "password": "a65gxjjvsr9phsmf" } // 保存到localStorage sessionStorage.setItem("dav_login_data", JSON.stringify(dav_login_data)) } return JSON.parse(sessionStorage.getItem("dav_login_data")) }, request: function (method, path, callback, responseType = 'text', data = null) { let login_data = this.get_login_data() return new Promise((resolve) => { GM_xmlhttpRequest({ method: method, data: data, url: login_data.baseURL + path, headers: { 'Authorization': 'Basic ' + btoa(login_data.username + ':' + login_data.password), }, responseType: responseType, onload: async (response) => { callback(response, resolve) }, onerror: (error) => { alert(error) } }) }) }, get_file_data: function (file_path) { let callback = function (response, resolve) { resolve(response.responseText) } return this.request('GET', file_path, callback, 'text') }, get_file_last_modified_time: function (file_path) { let callback = function (response, resolve) { resolve(response.responseXML.getElementsByTagName('d:getlastmodified')[0].textContent) } return this.request('PROPFIND', file_path, callback, 'document', '') }, upload_file_through_file_data: function (file_path, file_data) { let callback = function () { } this.request('PUT', file_path, callback, 'text', file_data) }, upload_file_through_url: async function (file_path, url) { function get_url_file_data(url) { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: "GET", url: url, responseType: "arraybuffer", onload: (response) => { resolve(new Blob([response.response])) }, onerror: () => { reject('error'); } }) }) } let file_data = await get_url_file_data(url) this.upload_file_through_file_data(file_path, file_data) }, check_path_exists: function (path) { let callback = function (response, resolve) { if (response.status === 404) { resolve(false) } else { resolve(true) } } return this.request('PROPFIND', path, callback, 'text', '') }, create_dir_path: async function (dir_path) { let callback = function () { } try { let dir_exits = await this.check_path_exists(dir_path) if (dir_exits) { return } let currentPath = dir_path while (currentPath) { dir_exits = await this.check_path_exists(currentPath); if (dir_exits) { break } // 尝试创建目录 await this.request('MKCOL', currentPath, callback, 'text', ''); // 截取到上一级目录 const lastIndex = currentPath.lastIndexOf('/'); if (lastIndex === -1) { break } currentPath = currentPath.slice(0, lastIndex) } } catch (error) { console.error(`Error creating directory ${dir_path}:`, error); } }, get_latest_modified_file: async function (dir_path) { let callback = function (response, resolve) { if (response.status === 404) { resolve("error") } else { resolve(response.responseXML.firstChild.lastChild.firstElementChild.innerHTML) } } return this.request('PROPFIND', dir_path, callback, 'text', '') } }