forked from Wikidepia/InstaFix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.js
39 lines (35 loc) · 1.15 KB
/
worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
addEventListener("fetch", event => {
event.respondWith(stream(event.request))
});
async function stream(request) {
const {
searchParams
} = new URL(request.url)
let url = searchParams.get('url')
let referer = searchParams.get('referer')
// Fetch from origin server.
let response = await fetch(url, {
"headers": {
"accept": "*/*",
"accept-language": "id-ID,id",
"range": "bytes=0-",
"referer": referer,
"sec-ch-ua": "\" Not;A Brand\";v=\"99\", \"Google Chrome\";v=\"109\", \"Chromium\";v=\"109\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"macOS\"",
"sec-fetch-dest": "video",
"sec-fetch-mode": "no-cors",
"sec-fetch-site": "cross-site"
},
"body": null,
"method": "GET",
});
const responseInit = {
headers: {
'Content-Length': response.headers.get('Content-Length'),
'Content-Type': 'video/mp4',
'Content-Disposition': 'attachment; filename="video.mp4"'
}
};
return new Response(response.body, responseInit)
}