-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathcookie.js
40 lines (33 loc) · 853 Bytes
/
cookie.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
const fetch = require("node-fetch").default
const { Octokit } = require("@octokit/rest")
const octokit = new Octokit({
auth: process.env.AUTH_TOKEN
})
const GIST = process.env.GIST
const getCookie = async () => {
const { data } = await octokit.gists.get({
gist_id: GIST,
})
const cookie = data.files["cookie"].content
return cookie
}
const regenerateCookie = async (cookie) => {
const r = await fetch("https://2049bbs.xyz", {
headers: {
Cookie: cookie
}
})
const cookies = r.headers.get("set-cookie")
return cookies.match(/SessionID=.+?(;|$)/)[0]
}
getCookie().then(regenerateCookie).then(c => {
console.log(c)
return octokit.gists.update({
gist_id: GIST,
files: {
"cookie": {
content: c
}
}
})
})