Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lightapis/userscript-with-webdav
Connect WebDAV in the Tampermonkey/Violentmonkey script
https://github.com/lightapis/userscript-with-webdav
tampermonkey userscript violentmonkey webdav
Last synced: 9 days ago
JSON representation
Connect WebDAV in the Tampermonkey/Violentmonkey script
- Host: GitHub
- URL: https://github.com/lightapis/userscript-with-webdav
- Owner: LightAPIs
- License: mit
- Created: 2023-10-03T09:11:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-01T11:25:54.000Z (2 months ago)
- Last Synced: 2025-01-26T15:47:48.077Z (9 days ago)
- Topics: tampermonkey, userscript, violentmonkey, webdav
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/userscript-with-webdav
- Size: 47.9 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# userscript-with-webdav
Connect WebDAV in the Tampermonkey/Violentmonkey script.
## Installation
in userscript:
```jsvascript
// @require https://cdn.jsdelivr.net/npm/userscript-with-webdav@latest/index.iife.js
// @grant GM_xmlhttpRequest
// @connect *
```or embed:
```shell
npm install userscript-with-webdav
```## Usage
Example:
```typescript
// When embed:
import Webdav from 'userscript-with-webdav';(async () => {
const wh = new Webdav('', '', '');// download
try {
const res = await wh.download('path/to/your/file');
console.log('status:', res.status);
console.log('data:', res.data);
} catch (err) {
if (err instanceof Webdav.NotFound) {
console.error('file does not exist');
} else if (err instanceof Webdav.Unauthorized) {
console.error('authentication failed');
}
}// upload
try {
await wh.upload('path/to/your/file', '');
} catch (err) {
if (err instanceof Webdav.Forbidden) {
console.error('permission error');
}
}
})();
```## Type
```typescript
declare class Webdav {
static InternalError: typeof InternalError;
static Unauthorized: typeof Unauthorized;
static Forbidden: typeof Forbidden;
static NotFound: typeof NotFound;
static Redirection: typeof Redirection;
static ClientSideError: typeof ClientSideError;
static ServerSideError: typeof ServerSideError;
/**
* Constructor
* @param domainURL WebDAV domain
* @param user User name
* @param password User password
*/
constructor(domainURL?: string, user?: string, password?: string);
/**
* Generate validation request header
* @returns Verification request header
*/
updateConfig(domainURL: string, user: string, password: string): void;
/**
* Download file content
* @param fileURL Relative file URL
* @returns Response
*/
download(fileURL: string): Promise;
/**
* Upload file content
* @param fileURL Relative file URL
* @param data Data
* @returns Response
*/
upload(fileURL: string, data: string): Promise;
}declare interface ConnectionResponse {
/** Response status code */
status: number;
/** Response data */
data: string;
}
```## License
[MIT](./LICENSE)