Created
May 24, 2024 08:02
-
-
Save abersheeran/4838fe4287f7ba4dda64165fc8ffd15e to your computer and use it in GitHub Desktop.
领取 bilibili 大会员权益
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getCSRFToken() { | |
let bilijct = ""; | |
document.cookie | |
.split(";") | |
.filter((cookie) => cookie.includes("bili_jct")) | |
.forEach((cookie) => { | |
const [name, value] = cookie.split("="); | |
bilijct = value; | |
}); | |
return bilijct; | |
} | |
let api_url = "https://api.bilibili.com/x/vip/privilege/receive"; | |
let form = new FormData(); | |
form = new FormData(); | |
form.append("type", "1"); | |
form.append("platform", "web"); | |
form.append("csrf", getCSRFToken()); | |
fetch(api_url, { | |
method: "POST", | |
body: form, | |
credentials: "include", | |
}) | |
.then((response) => response.json()) | |
.then((data) => { | |
console.log(data); | |
}); | |
form = new FormData(); | |
form.append("type", "3"); | |
form.append("platform", "web"); | |
form.append("csrf", getCSRFToken()); | |
fetch(api_url, { | |
method: "POST", | |
body: form, | |
credentials: "include", | |
}) | |
.then((response) => response.json()) | |
.then((data) => { | |
console.log(data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment