https://github.com/tajpouria/sw-schedule-caller
A quick script in order to performing some action in particular time schedule
https://github.com/tajpouria/sw-schedule-caller
script service-worker
Last synced: 10 months ago
JSON representation
A quick script in order to performing some action in particular time schedule
- Host: GitHub
- URL: https://github.com/tajpouria/sw-schedule-caller
- Owner: tajpouria
- Created: 2020-02-03T09:20:57.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-04T17:51:36.000Z (over 6 years ago)
- Last Synced: 2025-08-30T03:54:53.557Z (11 months ago)
- Topics: script, service-worker
- Language: JavaScript
- Size: 37.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sw-schedule-caller
A quick script in order to calling some api in particular time schedule from service-worker
## Usage
It's Pretty straight forward!
1. Register [ ./sw.js ](./sw.js)
2. Change `SCHEDULE` and `API_TO_CALL` inside the [ ./sw.js ](./sw.js)
## Example
[ ./sw.js ](./sw.js)
```js
const SCHEDULE = { from: "02:10:00:00", till: "06:50:00:00" }; // hh:mm:ss:ms 24H
const API_TO_CALL = {
from: {
url: "http://127.0.0.1:6800/jsonrpc",
options: {
method: "POST",
headers: {
"Content-Type": "application/json",
mode: "cors",
cache: "no-cache",
credentials: "same-origin",
Accept: "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "aria2.unpauseAll",
params: [],
}),
},
},
till: {
url: "http://127.0.0.1:6800/jsonrpc",
options: {
method: "POST",
headers: {
"Content-Type": "application/json",
mode: "cors",
cache: "no-cache",
credentials: "same-origin",
Accept: "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "aria2.pauseAll",
params: [],
}),
},
},
};
```
