Skip to content

Commit e08cc13

Browse files
LightLight
Light
authored and
Light
committed
feat: Function implementation
0 parents  commit e08cc13

11 files changed

+2219
-0
lines changed

.eslintrc.cjs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/recommended"
10+
],
11+
"overrides": [
12+
],
13+
"parser": "@typescript-eslint/parser",
14+
"parserOptions": {
15+
"ecmaVersion": "latest",
16+
"sourceType": "module"
17+
},
18+
"plugins": [
19+
"@typescript-eslint"
20+
],
21+
"rules": {
22+
}
23+
}

.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
publish
14+
*.local
15+
16+
# Editor directories and files
17+
.vscode/*
18+
!.vscode/extensions.json
19+
.idea
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Light
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# userscript-with-webdav
2+
3+
Connect WebDAV in the Tampermonkey/Violentmonkey script.
4+
5+
## Installation
6+
7+
in userscript:
8+
9+
```jsvascript
10+
// @require https://cdn.jsdelivr.net/npm/userscript-with-webdav@latest/index.iife.js
11+
// @grant GM_xmlhttpRequest
12+
// @connect *
13+
```
14+
15+
or embed:
16+
17+
```shell
18+
npm install userscript-with-webdav
19+
```
20+
21+
## Usage
22+
23+
When embed:
24+
25+
```javascript
26+
import Webdav from 'userscript-with-webdav';
27+
```
28+
29+
## Type
30+
31+
```typescript
32+
class Webdav {
33+
/**
34+
* Constructor
35+
* @param domainURL WebDAV domain
36+
* @param user User name
37+
* @param password User password
38+
*/
39+
constructor(domainURL: string, user: string, password: string);
40+
/**
41+
* Download file content
42+
* @param fileURL Relative file URL
43+
* @returns Response
44+
*/
45+
download(fileURL: string): Promise<{
46+
status: number;
47+
data: string;
48+
} | {
49+
status: number;
50+
data: null;
51+
}>;
52+
/**
53+
* Upload file content
54+
* @param fileURL Relative file URL
55+
* @param data Data
56+
* @returns Response
57+
*/
58+
upload(fileURL: string, data: string): Promise<{
59+
status: number;
60+
data: any;
61+
}>;
62+
}
63+
```
64+
65+
## License
66+
67+
[MIT](./LICENSE)

package.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "userscript-with-webdav",
3+
"type": "module",
4+
"private": false,
5+
"version": "0.1.0",
6+
"description": "Connect WebDAV in the Tampermonkey/Violentmonkey script",
7+
"author": "Light",
8+
"license": "MIT",
9+
"homepage": "https://github.com/LightAPIs/userscript-with-webdav",
10+
"repository": "LightAPIs/userscript-with-webdav",
11+
"main": "index.js",
12+
"scripts": {
13+
"dev": "vite",
14+
"build": "vite build"
15+
},
16+
"keywords": [
17+
"webdav",
18+
"userscript",
19+
"tampermonkey",
20+
"violentmonkey"
21+
],
22+
"publishConfig": {
23+
"directory": "publish"
24+
},
25+
"devDependencies": {
26+
"@types/tampermonkey": "4.20.3",
27+
"@typescript-eslint/eslint-plugin": "^6.7.4",
28+
"@typescript-eslint/parser": "^6.7.4",
29+
"eslint": "^8.50.0",
30+
"rollup-plugin-copy": "^3.5.0",
31+
"typescript": "^5.2.2",
32+
"vite": "^4.4.9",
33+
"vite-plugin-dts": "^3.6.0"
34+
},
35+
"pnpm": {
36+
"patchedDependencies": {
37+
"@types/tampermonkey@4.20.3": "patches/@types__tampermonkey@4.20.3.patch"
38+
}
39+
}
40+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/index.d.ts b/index.d.ts
2+
index 5bd1df50a8e097e681e438716f95eca1e2dee0de..c126e589384ebcce990f2c7d994c7fca8fa81afa 100644
3+
--- a/index.d.ts
4+
+++ b/index.d.ts
5+
@@ -73,7 +73,7 @@ declare namespace Tampermonkey {
6+
type RequestEventListener<TResponse> = (this: TResponse, response: TResponse) => void;
7+
8+
interface Request<TContext = object> {
9+
- method?: "GET" | "HEAD" | "POST";
10+
+ method?: 'GET' | 'HEAD' | 'POST' | 'PUT';
11+
/** The destination URL */
12+
url: string;
13+
/**

0 commit comments

Comments
 (0)