We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
调用此 API,可以操控脚本同步配置的文件储存源,将会在设定目录下创建一个app目录供此 API 使用.
脚本同步
app
API 定义如下
/** * 操控脚本同步配置的文件储存源,将会在同步目录下创建一个app/(uuid或者storageName)目录供此 API 使用 * 当声明了@storageName时,将会将文件上传至指定的@storageName目录,多个脚本也可用此声明公用一个文件夹 * 上传时默认覆盖同名文件 * @param action 操作类型 list 列出指定目录所有文件, upload 上传文件, download 下载文件, delete 删除文件 */ declare function CAT_fileStorage( action: "list", details: { path?: string; onload?: (files: CATType.FileStorageFileInfo[]) => void; onerror?: (error: FileStorageError) => void; } ): void; declare function CAT_fileStorage( action: "download", details: { filename: string; onload: (data: Blob) => void; onprogress?: (progress: number) => void; onerror?: (error: FileStorageError) => void; } ): void; declare function CAT_fileStorage( action: "delete", details: { filename: string; onload?: () => void; onerror?: (error: FileStorageError) => void; } ): void; declare function CAT_fileStorage( action: "upload", details: { filename: string; data: Blob; onload?: () => void; onprogress?: (progress: number) => void; onerror?: (error: FileStorageError) => void; } ): void; interface FileStorageError { // 错误码 1 用户未配置文件储存源 2 文件储存源配置错误 3 路径不存在 // 4 文件不存在 5 文件已存在 6 上传失败 7 下载失败 8 删除失败 code: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8; msg: string; } interface FileStorageFileInfo { path: string; name: string; size: number; isDir: boolean; }
论坛帖子: 脚本猫新API CAT_fileStorage 提案 https://bbs.tampermonkey.net.cn/thread-3881-1-1.html (出处: 油猴中文网)
The text was updated successfully, but these errors were encountered:
✨ 实现CAT_fileStorage #127
d566afb
一个例子
// ==UserScript== // @name cat file storage // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.1.0 // @description 脚本同步储存空间操作 // @author You // @match https://bbs.tampermonkey.net.cn/ // @grant CAT_fileStorage // ==/UserScript== CAT_fileStorage("upload", { path: "test.txt", data: new Blob(["Hello World"]), onload() { CAT_fileStorage("list", { onload(list) { console.log(list); list.forEach(value => { if (value.name === "test.txt") { CAT_fileStorage("download", { file: value, async onload(data) { console.log(await data.text()); CAT_fileStorage("delete", { path: value.name, onload() { console.log('ok'); } }); } }); } }); } }) } })
Sorry, something went wrong.
When branches are created from issues, their pull requests are automatically linked.
调用此 API,可以操控
脚本同步
配置的文件储存源,将会在设定目录下创建一个app
目录供此 API 使用.API 定义如下
论坛帖子:
脚本猫新API CAT_fileStorage 提案
https://bbs.tampermonkey.net.cn/thread-3881-1-1.html
(出处: 油猴中文网)
The text was updated successfully, but these errors were encountered: